The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.
TypeScript code-editorcross-platformdapdatabase-clientdebuggerdesktop-appdeveloper-toolsgithttp-clientideintellijlsprusttauriterminal
fix(database): table editor focus when the tab opens targets the editor host (#2307) (#2318)
arookieofc687471c19e3b
diff --git a/src/features/database/table-editor.test.tsx b/src/features/database/table-editor.test.tsxindex 32687106a..2980a62c5 100644--- a/src/features/database/table-editor.test.tsx+++ b/src/features/database/table-editor.test.tsx@@ -125,4 +125,29 @@ describe("table editor capabilities", () => {uninstall();}});++ it("counts the editor-area host focusing the tab as table-editor focus (#2307)", async () => {+ backend.driver = "postgres";+ const uninstall = installTableEditorFocus();+ try {+ let root!: HTMLElement;+ await act(async () => {+ const r = render(<TableEditor input={tableInput("source", "public", "users")} />);+ root = r.container;+ });+ // Mimic EditorArea wrapping the tab in its focusable host, then focusing the host on open.+ const host = root.closest("div")!;+ host.setAttribute("data-editor-focus", "");+ host.tabIndex = -1;+ act(() => host.focus());+ expect(getContext()).toMatchObject({ dbTableEditorFocus: true, dbTableEditorChanges: false });+ // A later focus inside a text field still turns it off.+ const input = document.createElement("input");+ root.querySelector("[data-db-table-editor]")!.appendChild(input);+ act(() => input.focus());+ expect(getContext().dbTableEditorFocus).toBe(false);+ } finally {+ uninstall();+ }+ });});diff --git a/src/features/database/tableEditorFocus.ts b/src/features/database/tableEditorFocus.tsindex 22bdb5bf5..4453d2f92 100644--- a/src/features/database/tableEditorFocus.ts+++ b/src/features/database/tableEditorFocus.ts@@ -23,7 +23,11 @@ function update() {function onFocusIn(event: FocusEvent) {const target = event.target instanceof Element ? event.target : null;- const root = target?.closest("[data-db-table-editor]");+ // The editor area focuses its host `[data-editor-focus]` when the tab opens —+ // treat that as focus inside a table editor so ⌘F12 / ⌘↩ work right away.+ const root =+ target?.closest("[data-db-table-editor]") ??+ (target?.hasAttribute("data-editor-focus") ? target.querySelector("[data-db-table-editor]") : null);active = (root && !isTextField(target!) && handles.get(root)) || null;update();}