fix(query): isolate duplicated tab rename state
This commit is contained in:
parent
234f26ada8
commit
b7e3b2ee57
|
|
@ -129,8 +129,12 @@ function startRenameTab(tab: QueryTab) {
|
|||
editingTitle.value = tab.title;
|
||||
nextTick(() => {
|
||||
const input = document.querySelector<HTMLInputElement>(`[data-tab-title-input="${tab.id}"]`);
|
||||
input?.focus();
|
||||
input?.select();
|
||||
if (input) {
|
||||
input.focus();
|
||||
const dotIndex = input.value.lastIndexOf(".");
|
||||
const selectEnd = dotIndex > 0 ? dotIndex : input.value.length;
|
||||
input.setSelectionRange(0, selectEnd);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1933,7 +1933,9 @@ export const useQueryStore = defineStore("query", () => {
|
|||
database: original.database,
|
||||
schema: original.schema,
|
||||
sql: original.sql,
|
||||
savedSqlId: original.savedSqlId,
|
||||
originalSql: "",
|
||||
savedSqlId: undefined,
|
||||
externalSqlPath: undefined,
|
||||
lastExecutedSql: undefined,
|
||||
resultBaseSql: original.resultBaseSql,
|
||||
resultSortedSql: undefined,
|
||||
|
|
|
|||
|
|
@ -6119,6 +6119,25 @@ test("duplicating a table structure tab clones its unsaved draft", () => {
|
|||
assert.equal(tab.structureDraft.columns[0]!.name, "draft_name");
|
||||
});
|
||||
|
||||
test("duplicateTab does not inherit savedSqlId or externalSqlPath", () => {
|
||||
setActivePinia(createPinia());
|
||||
const store = useQueryStore();
|
||||
|
||||
const tabId = store.createTab("conn-1", "db", "A", "query");
|
||||
const tab = store.tabs.find((t) => t.id === tabId)!;
|
||||
tab.savedSqlId = "saved-sql-1";
|
||||
tab.externalSqlPath = "/path/to/sql";
|
||||
tab.sql = "SELECT 1;";
|
||||
|
||||
store.duplicateTab(tabId);
|
||||
|
||||
const copy = store.tabs.find((item) => item.id !== tabId)!;
|
||||
assert.equal(copy.savedSqlId, undefined);
|
||||
assert.equal(copy.externalSqlPath, undefined);
|
||||
assert.equal(copy.originalSql, "");
|
||||
assert.equal(store.isTabDirty(copy), true);
|
||||
});
|
||||
|
||||
test("reorderTab keeps pinned tabs before unpinned tabs after reorder", () => {
|
||||
setActivePinia(createPinia());
|
||||
const store = useQueryStore();
|
||||
|
|
|
|||
Loading…
Reference in New Issue