fix(desktop): respect table tab reuse policy on editor table click

This commit is contained in:
rihkddd
2026-08-11 00:08:18 +08:00
committed by GitHub
parent 745f24322f
commit 04580355d0
2 changed files with 16 additions and 2 deletions
+2 -2
View File
@@ -1709,7 +1709,7 @@ async function onClickTable(table: SqlObjectNavigationTarget) {
return;
}
try {
await openTableTarget(target, { tableInfoTab: "ddl" });
await openObjectBrowserTableTarget(target);
} catch (e: any) {
toast(t("connection.connectFailed", { message: translateBackendError(t, e) }), 5000);
}
@@ -1719,7 +1719,7 @@ async function onViewTableData(table: SqlObjectNavigationTarget) {
const target = tableTargetFromActiveTab(table);
if (!target) return;
try {
await openTableTarget(target);
await openObjectBrowserTableTarget(target);
} catch (e: any) {
toast(t("connection.connectFailed", { message: translateBackendError(t, e) }), 5000);
}
@@ -217,6 +217,20 @@ describe("useNavigationTargets with the real query store", () => {
expect(queryStore.activeTabId).toBe(sidebarTabId);
});
it("reuses existing table tab when navigating via object browser target in same-table mode", async () => {
mocks.settingsStore.editorSettings.dataTabReuseMode = "same-table";
const { navigation, queryStore } = await setupNavigation();
const target = { connectionId: "connection-1", database: "app", schema: "public", tableName: "users", tableType: "TABLE" };
await navigation.openObjectBrowserTableTarget(target);
const firstTabId = queryStore.activeTabId;
await navigation.openObjectBrowserTableTarget(target);
expect(queryStore.tabs).toHaveLength(1);
expect(queryStore.activeTabId).toBe(firstTabId);
});
it("reuses a restored legacy MySQL tab when the same table is opened from the sidebar", async () => {
mocks.connectionStore.getConfig.mockImplementation((connectionId: string) => ({ id: connectionId, db_type: "mysql" }));
mocks.loadOpenTabsState.mockResolvedValue({