fix(connection): fix new connection dialog title focus

This commit is contained in:
zipg authored and GitHub committed 2026-07-24 23:49:53 +08:00
1 parent f2ce70dd68
commit 80ef2e579e
2 files changed
+15 -12

No files matched your search

@@ -4,9 +4,11 @@ import { describe, expect, it } from "vitest";
const dialogSource = readFileSync(new URL("../../../components/connection/ConnectionDialog.vue", import.meta.url), "utf8");
describe("connection dialog accessibility", () => {
it("moves initial focus to the dialog title instead of the dialog container", () => {
expect(dialogSource).toContain('<DialogTitle data-connection-dialog-title tabindex="-1">');
expect(dialogSource).toContain('querySelector<HTMLElement>("[data-connection-dialog-title]")?.focus({ preventScroll: true })');
it("moves initial focus to an input inside the dialog", () => {
expect(dialogSource).toContain('<Input v-model="dbSearchQuery" v-connection-dialog-auto-focus');
expect(dialogSource).toContain('<Input v-model="form.name" v-connection-dialog-auto-focus');
expect(dialogSource).toContain("const vConnectionDialogAutoFocus: ObjectDirective<HTMLInputElement>");
expect(dialogSource).toContain("input.focus({ preventScroll: true })");
expect(dialogSource).not.toMatch(/<DialogContent[^>]*\stabindex="-1"/);
});