fix(grid): preserve column filters on refresh

This commit is contained in:
t8y2 2026-05-21 14:53:13 +08:00
parent f7f39f124c
commit 12a1032e1b
2 changed files with 19 additions and 1 deletions

View File

@ -1147,8 +1147,21 @@ function onScrollerScroll(e: Event) {
initColumnWidths();
watch(() => visibleColumns.value.length, initColumnWidths);
const localFilterScopeKey = computed(() =>
[
props.connectionId ?? "",
props.database ?? "",
props.schema ?? "",
props.context ?? "",
props.tableMeta?.schema ?? "",
props.tableMeta?.tableName ?? "",
props.tableMeta ? "" : (props.sql ?? ""),
props.result.columns.join("\0"),
(props.sourceColumns ?? []).map((column) => column ?? "").join("\0"),
].join("\u0001"),
);
watch(
() => props.result,
() => localFilterScopeKey.value,
() => {
localColumnFilters.value = {};
hiddenColumnIndexes.value = new Set();

View File

@ -17,3 +17,8 @@ test("rollback refresh preserves header sort order", () => {
assert.match(match[1], /currentOrderBy\(\)/);
assert.doesNotMatch(match[1], /orderByInput\.value\.trim\(\) \|\| undefined/);
});
test("data result refresh preserves local column filters", () => {
assert.doesNotMatch(source, /watch\(\s*\(\)\s*=>\s*props\.result,[\s\S]*?localColumnFilters\.value\s*=\s*\{\}/);
assert.match(source, /localFilterScopeKey/);
});