Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: clear unnecessary view state when adding new tab (#14094)

Liu Ji2e1c64282e69
diff --git a/frontend/src/views/sql-editor/EditorPanel/context/index.ts b/frontend/src/views/sql-editor/EditorPanel/context/index.ts
index ef945b9ae2..5bf624ad54 100644
--- a/frontend/src/views/sql-editor/EditorPanel/context/index.ts
+++ b/frontend/src/views/sql-editor/EditorPanel/context/index.ts
@@ -74,7 +74,9 @@ export const provideEditorPanelContext = (base: {
const cloneViewState = (from: string, to: string) => {
const vs = viewStateByTab.get(from);
if (!vs) return;
- viewStateByTab.set(to, cloneDeep(vs));
+ const cloned = cloneDeep(vs);
+ viewStateByTab.set(to, cloned);
+ return cloned;
};
watch(
diff --git a/frontend/src/views/sql-editor/TabList/TabList.vue b/frontend/src/views/sql-editor/TabList/TabList.vue
index 2e878bcddb..fa608b6e18 100644
--- a/frontend/src/views/sql-editor/TabList/TabList.vue
+++ b/frontend/src/views/sql-editor/TabList/TabList.vue
@@ -142,7 +142,11 @@ const handleAddTab = () => {
);
const newTab = tabStore.addTab(clonedTab);
if (fromTab) {
- cloneViewState(fromTab.id, newTab.id);
+ const vs = cloneViewState(fromTab.id, newTab.id);
+ if (vs) {
+ vs.view = "CODE";
+ vs.detail = {};
+ }
}
nextTick(recalculateScrollState);
sheetEvents.emit("add-sheet");