Focus the navigable region on Escape - #82310
Open
ellatrix wants to merge 8 commits into
Open
Conversation
Pressing Escape anywhere inside a region moves focus onto the region itself, and pressing it on a region cycles to the next one, backwards with Shift. Anything that already handles the key, a popover, a modal, the undo of an automatic change, the collapse of a multi selection, keeps winning: the region navigation waits a microtask and only acts when nothing else claimed the press, since listeners delegated at the document level run after this handler within the same dispatch. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🤖 PR meta 🤖📦 Bundle sizeSize Change: +415 B (+0.01%) Total Size: 8 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
|
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Cycling with a closed panel landed focus on its empty region wrapper, making the focus indicator vanish. Regions without a visible box are skipped now. The floating block toolbar becomes a labelled region, so the cycle reaches it right after the content, matching the original regions proposal. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
At region level the page's focus stops are the regions, so Tab moves between them and Shift+Tab back, wrapping at the ends. Enter goes into the region: to the place focus last left it from, remembered when Escape steps out, descending into same-origin frames, or to its first tabbable. Escape on a region does nothing further; there is nowhere higher. Entering a region moves off the wrapper, so the existing tests that tabbed straight from a focused region into its content now press Enter first. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The closed publish panel keeps only a toggle the region's own focus reveals, so skipping regions by visible size alone removed it from the cycle. A region is skipped only when it has no visible box and nothing tabbable inside. The block toolbar floats over the content, preceding it visually, so a region nested in another now comes before its container in the cycle. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The toolbar floats visibly inside the content region's focus outline, so it follows the content in the cycle rather than preceding it. That is plain document order for a nested region, so the reordering pass goes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The rule skipping regions without a visible box or anything tabbable is gone. The shortcut cycle never filtered, and the one region it was written around, the closed publish panel, belongs in the cycle anyway: focusing it reveals its toggle. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Escape stepped focus out onto the region, so pressing it again returns to where focus came from. Same restore path as Enter. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ellatrix
marked this pull request as ready for review
September 2, 2026 03:59
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Escape currently does nothing in the editor.
Tab on the over hand is overloaded. In some contexts it manipulates the content (indent), and otherwise it moves focus to the inspector. Quite confusing.
I would say resolving this conflict is blocking further progress on several iterations:
useMerge, consider preventing propagation of Tab/Shift-Tab keypress even if unable to indent/outdent #82184.Additionally Tab can also easily be "trapped" by third party block that render editors like CodeMirror etc.
Solution
What would be the most natural key to press when being trapped? Escape, I'd say.
What if Escape moves focus to the navigable region (ARIA landmarks)? From there, it's so easy to get anywhere on the page: the block toolbar, inspector, header, publish panel, etc. This is currently quite clunky to get to with a hard to remember key combination. Once you Escape to a region, Tab and Shift+Tab can be used to cycle through these regions. Press Enter (or Escape) to... enter it. Escaping to a region can not only be used from the editor, but from anywhere.
I proposed this a while ago in #45157, but the feedback was that Escape is already used to switch back to browse mode in JAWS/NVDA. That's true, but I don't think it's a blocker. For people who use screen readers, it will simply take two Escape presses to navigate to the region, where the first press escapes the "focus mode" use for writing in blocks. When already in "browse mode", it just takes one press. On top of that, screen readers have their own dedicated keys to navigate regions/landmarks, so they have a lesser need of it.
It's also worth noting that the ARIA documentation prescribes nothing in terms of keyboard shortcuts to navigate landmark/regions. We have a very strange keyboard combination that is not standard at all, so there's nothing really to lose there.
Demo
region-navigation.mp4
With a screen reader, first NVDA with its Speech Viewer transcribing the announcements, then JAWS with its virtual cursor highlight. The extra first Escape is the screen reader leaving its typing mode; Escape then steps out, Tab visits every region by name, and Escape on the region goes back in, where typing resumes at the same spot:
region-navigation-screen-readers.mp4
Testing Instructions
*), closes popovers, and collapses a multi selection first.New e2e coverage in
test/e2e/specs/editor/various/escape-region-navigation.spec.js.Written with the help of an AI assistant.