дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 19:25:54 +02:00
The editor area focuses its own [data-editor-focus] host when a table tab opens; dbTableEditorFocus only set when focus landed inside [data-db-table-editor], so Go to Column / Submit / Revert stayed disabled until a cell was clicked. Treat host focus that wraps a table editor as table-editor focus too.
Цей коміт міститься в:
1 джерело
a46d873f6c
коміт
687471c19e
2 files changed
+30
-1
No files matched your search
@@ -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();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in new issue
Заблокувати користувача