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
Check · Review · Land · Live done — Landed and live in production.
torque/forge:torque/13586-the-toolbar-s-panel-closes-on-escape-and → main 1 commit fork
1 file
changed +22
−0
test/toolbar-keyboard.test.ts +22
| @@ -154,6 +154,25 @@ describe.skipIf(chromium === undefined)("the pill by keyboard", () => { | ||
| 154 | 154 | expect(await inside()).toBe("notes, production"); |
| 155 | 155 | }, 30_000); |
| 156 | 156 | |
| 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 | ||
| 157 | 176 | test("Space opens it too", async () => { |
| 158 | 177 | await evaluate(`document.getElementById("last").focus()`); |
| 159 | 178 | await tab(); |
| @@ -175,6 +194,9 @@ describe("the note form, from the shipped script", () => { | ||
| 175 | 194 | expect(toolbarJs).toContain("tellText.focus()"); |
| 176 | 195 | expect(toolbarJs).toMatch(/e\.key !== "Escape"[^]*?set\(false\);\s*pill\.focus\(\)/); |
| 177 | 196 | }); |
| 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 | }); | |
| 178 | 200 | test("the form's controls have labels", () => { |
| 179 | 201 | expect(toolbarJs).toContain('tellBox.setAttribute("aria-label"'); |
| 180 | 202 | expect(toolbarJs).toContain('tellText.setAttribute("aria-label"'); |
new above
offline