fix: 表头筛选回车直接筛选匹配项 (#1261)
This commit is contained in:
parent
018b719257
commit
09a30cd980
@ -3086,7 +3086,21 @@
|
||||
filterSearch.addEventListener('input', showFilterOptions);
|
||||
filterSearch.addEventListener('keydown', (event) => {
|
||||
if (event.key !== 'Enter' || !activeFilter) return;
|
||||
if (event.isComposing || event.keyCode === 229) return;
|
||||
event.preventDefault();
|
||||
const normalizedQuery = filterSearch.value.trim().toLocaleLowerCase('zh-CN');
|
||||
if (normalizedQuery !== '') {
|
||||
const matchingValues = activeFilter.values.filter(
|
||||
(value) => value.toLocaleLowerCase('zh-CN').includes(normalizedQuery),
|
||||
);
|
||||
if (matchingValues.length === 0) return;
|
||||
activeFilter.selection = new Set(matchingValues);
|
||||
activeFilter.state.filter = matchingValues.length === activeFilter.values.length
|
||||
? null
|
||||
: new Set(matchingValues);
|
||||
activeFilter.applyTable();
|
||||
filterCount.textContent = `全部账户 · 已选 ${activeFilter.selection.size} / ${activeFilter.values.length}`;
|
||||
}
|
||||
activeFilter.applyServer();
|
||||
});
|
||||
sortButtons.forEach((button) => {
|
||||
|
||||
@ -444,6 +444,18 @@ class NonStoreAccountMonitorTest extends FeatureTestCase
|
||||
$this->assertStringNotContainsString('分页占位公司001', $tableMatch[0]);
|
||||
$this->assertStringContainsString('全部账户 · 已选', $html);
|
||||
$this->assertStringContainsString('data-nsm-filter-key="account_display_short"', $html);
|
||||
$this->assertStringContainsString(
|
||||
'const matchingValues = activeFilter.values.filter(',
|
||||
$html,
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
'activeFilter.selection = new Set(matchingValues);',
|
||||
$html,
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
'if (event.isComposing || event.keyCode === 229) return;',
|
||||
$html,
|
||||
);
|
||||
$this->assertSame(1, preg_match(
|
||||
'/const serverColumnFilterValues = (.*?);\s*const serverColumnFilters/s',
|
||||
$html,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user