Repository navigation
Style Book: Align keyboard focus with the header layout - #85497
salvatorecorsi wants to merge 8 commits into
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. |
|
Could a maintainer rerun the Chromium job? All 12 Style Book cases passed before the browser connection closed while running SearchableChipSelect, with |
What?
Fixes #52730.
Make keyboard focus follow the visible order of the Style Book header: the selected tab, then Close, then the preview.
Why?
Close appears to the right of the tabs but currently comes first in the DOM. Opening the Style Book focuses Close, and pressing Tab jumps back to the left. This is especially disorienting when using a screen magnifier.
How?
Pass the existing Close button into the Style Book header after its tab list, before the preview panels. Its positioning and close handlers stay the same. The action is retained when tabs are hidden or a revision is loading, and keeps focus when loading finishes if it was already focused. Revisions-only canvases keep Close first, followed by the selected Visual control and the preview. Preview canvases retain focus return without adding initial focus, Close or Escape handling; the extensible editor's separate StyleBookPreview is unchanged.
Testing Instructions
Testing Instructions for Keyboard
Open Style Book with the keyboard. Focus should start on the selected tab. Tab should move to Close, then into the preview; Shift+Tab should reverse that order. Arrow keys should still navigate the tabs. Escape from the header should close Style Book and return focus to its opener.
In a revisions-only canvas, focus starts on Close. Tab moves to the selected Visual radio, then the revision preview; Shift+Tab reverses that order. The unselected Code radio is reached with arrow keys within its radio group.
Chromium component tests cover the actual StylesCanvas, StyleBook, tab controls, Close button and focus hooks, with fixtures for backend data and preview contents. They cover the original focus-order regression, revision loading, hidden tabs, and focus return without stealing focus elsewhere. Focused tests, editor typecheck, lint, test conventions, production build and a scoped published-dependency audit passed. The audit used the local Windows junction adapter; the full default audit was not run. The routing check has the same Windows discovery failure reproduced on unchanged trunk.
Also verified with Playwright against the actual built checkout in a native WordPress Site Editor: keyboard opening, selected tab → Close → live preview, reverse Tab, arrow navigation, and Escape returning focus to the opener. This was a focused native check, not the full Docker E2E suite.
Screenshots or screencast
The visual layout is unchanged; the change is the order in which focus reaches the header controls.
Validation after trunk update (2026-11-02)
Merged trunk
66fa56fff04be859c093813a4ef9578f918525f9normally and validated head691ef23e0e8b905bc408244e535136bee6d544c2.Normal conflict-free merge of current trunk66fa56f after the initial c6 maintenance; the actual Style Book correction and every existing browser assertion are unchanged. Prior validation and the previous hosted Chromium crash log are preserved in phase1.
The previous native WordPress Site Editor proof remains historical; no fresh native-site or full Docker E2E run is claimed.
The required type label still needs maintainer action.
Validation update — 9 November 2026
Merged trunk
afa2c6a9baec79a4fdfb40ca59adaae410cc5feband validated published headb7efb1ba9206a266b77be755ee409582160488f6. This includes the required trunk baseline.These are local validation results; hosted CI and maintainer-only label requirements remain separate.
The revisions-only keyboard test was adapted to upstream #85288, which adds the Visual/Code control between Close and the preview. It now checks the exact selected Visual control and preview in both Tab directions; production focus behavior is unchanged.
Validation update — 20 November 2026
Resolved the actual conflicts by merging trunk
3c872fce8cff38d2a8d38cd48a62575895114fb8normally. Published head:75737bef7059ec4bf88cb649ba7d02bc16f481d2.The PR's own source and regression-test blobs are unchanged; upstream release notes are preserved and this PR's changelog entries remain under Unreleased.
These are local branch-update results. Hosted CI is tracked separately; no full Docker E2E or published-dependency audit is claimed for this update.
Use of AI Tools
Codex implemented the change, wrote and ran the tests, and performed automated review. No human review by the account owner is claimed.
A maintainer will need to apply
[Type] Bug; this account cannot set upstream labels.