mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-20 00:17:44 +00:00
fix(editor): restore focus after query tab switches
This commit is contained in:
@@ -6730,6 +6730,7 @@ watch([() => props.tabId, () => props.modelValue], ([tabId, val], [prevTabId]) =
|
||||
if (!view.value) return;
|
||||
if (tabId !== prevTabId) {
|
||||
activateTabDocument(prevTabId, tabId, val);
|
||||
if (props.autoFocus) restoreEditorFocus();
|
||||
return;
|
||||
}
|
||||
if (val !== view.value.state.doc.toString()) {
|
||||
|
||||
@@ -47,6 +47,10 @@ describe("QueryEditor auto focus wiring", () => {
|
||||
it("enables auto focus for query tabs", () => {
|
||||
expect(contentAreaSource).toMatch(/<QueryEditor[\s\S]*?:\s*auto-focus="autoFocus !== false"\s[\s\S]*?:model-value="activeTab\.sql"/);
|
||||
});
|
||||
|
||||
it("restores focus when the active query tab changes", () => {
|
||||
expect(queryEditorSource).toMatch(/if \(tabId !== prevTabId\) \{[\s\S]*?activateTabDocument\(prevTabId, tabId, val\);[\s\S]*?if \(props\.autoFocus\) restoreEditorFocus\(\);/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("QueryEditor toolbar focus", () => {
|
||||
|
||||
Reference in New Issue
Block a user