Public: anyone can read this; the crew can change it.

The toolbar's panel closes on Escape and returns focus to the button that opened it #13596

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

torque/forge:torque/13586-the-toolbar-s-panel-closes-on-escape-and → main 1 commit fork

  • Merged. torque/13586-the-toolbar-s-panel-closes-on-escape-and was merged into main as 8d243e0.

Review

Sign in to review this change.
1 file changed +22 −0
test/toolbar-keyboard.test.ts +22
@@ -154,6 +154,25 @@ describe.skipIf(chromium === undefined)("the pill by keyboard", () => {
154154 expect(await inside()).toBe("notes, production");
155155 }, 30_000);
156156
157 test("a closed panel's controls are out of the tab order: Tab leaves the pill for the page", async () => {
158 await evaluate(`document.getElementById("last").focus()`);
159 await tab();
160 await key("Enter", 13, "\r");
161 await key("Escape", 27);
162 expect(await expanded()).toBe("false");
163 // The closed panel is unrendered, so none of its controls can take focus.
164 expect(
165 await inRoot(
166 `var p = this.querySelector("[hidden]"); if (!p) return "no panel"; var n = 0; p.querySelectorAll("a, button, input, textarea").forEach(function (c) { if (c.getClientRects().length) n++; }); return String(n);`,
167 ),
168 ).toBe("0");
169 for (let i = 0; i < 3; i++) {
170 await tab();
171 if ((await outside()) !== "forge-toolbar") break;
172 }
173 expect(await outside()).not.toBe("forge-toolbar");
174 }, 30_000);
175
157176 test("Space opens it too", async () => {
158177 await evaluate(`document.getElementById("last").focus()`);
159178 await tab();
@@ -175,6 +194,9 @@ describe("the note form, from the shipped script", () => {
175194 expect(toolbarJs).toContain("tellText.focus()");
176195 expect(toolbarJs).toMatch(/e\.key !== "Escape"[^]*?set\(false\);\s*pill\.focus\(\)/);
177196 });
197 test("closing hides the panel by display, which also removes it from the tab order", () => {
198 expect(toolbarJs).toMatch(/panel\.hidden = !open;\s*panel\.style\.display = open \? "flex" : "none"/);
199 });
178200 test("the form's controls have labels", () => {
179201 expect(toolbarJs).toContain('tellBox.setAttribute("aria-label"');
180202 expect(toolbarJs).toContain('tellText.setAttribute("aria-label"');

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs