fix: 表头筛选回车直接筛选匹配项 (#1261)

This commit is contained in:
shanshi 2026-11-19 11:21:36 +08:00
parent 018b719257
commit 09a30cd980
2 changed files with 26 additions and 0 deletions

View File

@ -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) => {

View File

@ -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,