fix(grid): persist WHERE filter input across tab switches (closes #210)

whereFilterInput was a component-local ref that got lost when switching
tabs because DataGrid is destroyed and recreated via :key binding.

Store whereInput in the QueryTab state and pass it as initialWhereInput
prop so it survives tab switches.
This commit is contained in:
t8y2 committed 2026-05-11 12:24:08 +08:00
1 parent cb70625bd8
commit 8032c63727
4 files changed
+7 -1

No files matched your search

+3
View File
@@ -48,6 +48,7 @@ export function useDataGridActions(activeTab: ComputedRef<QueryTab | undefined>)
const tab = activeTab.value;
if (!tab) return;
if (tab.mode === "data" && tab.tableMeta) {
tab.whereInput = whereInput ?? "";
queryStore.updateSql(tab.id, buildTableSql(tab, { whereInput, orderBy }));
await queryStore.executeCurrentTab();
return;
@@ -72,6 +73,7 @@ export function useDataGridActions(activeTab: ComputedRef<QueryTab | undefined>)
async function onPaginate(offset: number, limit: number, whereInput?: string, orderBy?: string) {
const tab = activeTab.value;
if (!tab?.tableMeta) return;
tab.whereInput = whereInput ?? "";
const sql = buildTableSql(tab, { limit, offset, whereInput, orderBy });
queryStore.updateSql(tab.id, sql);
await queryStore.executeCurrentTab();
@@ -83,6 +85,7 @@ export function useDataGridActions(activeTab: ComputedRef<QueryTab | undefined>)
if (tab.mode === "data") {
if (!tab.tableMeta) return;
tab.whereInput = whereInput ?? "";
const orderBy = direction ? `${quoteIdent(tab, column)} ${direction.toUpperCase()}` : undefined;
const sql = buildTableSql(tab, { orderBy, whereInput });
queryStore.updateSql(tab.id, sql);