Skip to content

Style Book: Align keyboard focus with the header layout - #85497

Open
salvatorecorsi wants to merge 8 commits into
WordPress:trunkfrom
salvatorecorsi:fix/52730-style-book-focus-order
Open

salvatorecorsi wants to merge 8 commits into
WordPress:trunkfrom
salvatorecorsi:fix/52730-style-book-focus-order

Conversation

@salvatorecorsi

@salvatorecorsi salvatorecorsi commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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

  1. In the Site Editor, open Styles and then Style Book.
  2. Confirm the tabs and Close button retain their positions.
  3. Repeat while viewing a block's style settings and a Style Book revision. Close should remain available while the revision loads.
  4. In a revisions-only preview, verify Close → selected Visual control → revision preview, and the reverse order with Shift+Tab. Check the extensible site editor's Styles preview for unchanged close behavior.

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 66fa56fff04be859c093813a4ef9578f918525f9 normally and validated head 691ef23e0e8b905bc408244e535136bee6d544c2.

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.

  • Merged the six newer upstream UI/dependency commits, refreshed this checkout's own lockfile dependencies and passed the full production build and full repository typecheck.
  • On Vitest 5.0.5, the dedicated Chromium Style Book/StylesCanvas fixture passed all 12 cases; the related Node category tests passed two cases.
  • All three original production files and the browser regression fixture remain byte-identical to the previous maintenance head.
  • Scoped lint passed with zero errors and the two unchanged Function JSDoc warnings; formatting, conventions, changelog, TypeScript configuration, generated API docs and net PR diff checks passed.
  • Hosted build and test jobs completed successfully on this head.

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 afa2c6a9baec79a4fdfb40ca59adaae410cc5feb and validated published head b7efb1ba9206a266b77be755ee409582160488f6. This includes the required trunk baseline.

  • Full JavaScript build and TypeScript checks passed.
  • Related automated tests passed: 28 cases across 4 files (focused-tests-upstream-toolbar-formatted).
  • scoped JavaScript lint, package changelog checks, repository conventions, tsconfig validation, and diff whitespace checks passed.

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 3c872fce8cff38d2a8d38cd48a62575895114fb8 normally. 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.

  • The full production build and full repository typecheck passed.
  • Scoped functional tests passed: 28 cases in 4 file(s) (unit). Counts are executions within these scopes, not distinct tests across PRs.
  • Scoped lint, package changelog checks, tsconfig validation, test conventions and documentation generation/cleanliness checks passed.

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.

@github-actions github-actions Bot added the [Package] Editor /packages/editor label Oct 23, 2026
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: salvatorecorsi <salvatorecorsi@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

Copy link
Copy Markdown
Contributor Author

Could a maintainer rerun the Chromium job? All 12 Style Book cases passed before the browser connection closed while running SearchableChipSelect, with VITEST_BROWSER_CONNECTION_CLOSED and no failing assertion. The entire UI package in the exact CI merge matches its trunk base. The 20 active-fixture cases also pass locally with seed 195560; that Windows check does not cover the full Linux test order or establish a hosted-suite pass. My upstream access is read-only.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Editor /packages/editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Style book: Close button and tabs visual order and DOM order mismatch

1 participant