Skip to content

Block Editor: Keep the revision canvas read-only in preview mode - #84578

Merged
Mamaduka merged 8 commits into
WordPress:trunkfrom
mattcowan:fix/revisions-preview-editable-root
Nov 10, 2026
Merged

Mamaduka merged 8 commits into
WordPress:trunkfrom
mattcowan:fix/revisions-preview-editable-root

Conversation

@mattcowan

@mattcowan mattcowan commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes #84577

In the revisions screen, the canvas no longer becomes an editing host when a Paragraph or List Item block gets focus or a click.

Why?

In Chromium, Tab cannot move forward past a Paragraph block in the revision canvas. When the paragraph gets focus, the canvas body becomes an editing host (contenteditable="true") and Chromium moves focus to the body. The preview mode Tab handler ignores keys from the body, so the next Tab goes back to the first block. Keyboard users cannot reach the remaining blocks, the "Document changes" region, or the sidebar. A click on a paragraph causes the same result. The issue has the full trace.

How?

The private canHostEditableRoot selector now returns false when isPreviewMode is set. The selector is also added to the memoization dependants as a primitive value.

Two hooks enable the editing host, and both use this selector. useEditableRoot acts when a block is selected (the Tab path). useSelectionObserver acts when a collapsed selection lands in the selected block (the click path). An early return in useEditableRoot only, like the isPreviewMode checks in use-arrow-nav.js and use-drag-selection.js, does not fix the click path. In a test with only that change, a click on a paragraph still moved focus to the body. The selector change covers both hooks and the third caller, rich-text/index.jsx.

The normal editor does not change: isPreviewMode is not set there.

Testing Instructions

  1. Create a post with a Heading, an Image, and a Paragraph block. Publish it.
  2. Remove the Image, change the Paragraph text, and add a List block. Update the post.
  3. Open the Post sidebar and select "Revisions".
  4. In Chrome or Edge, click the "Restore" button, then press Tab until focus is on the Heading block.
  5. Press Tab again. Make sure that focus moves through each block in order, then to the "Document changes" region.
  6. Click the Paragraph block in the canvas, then press Tab. Make sure that focus moves to the next block.
  7. In the normal editor, add two paragraphs. Put the caret at the end of the first and press Shift+Down. Make sure that the selection extends into the second paragraph.

Testing Instructions for Keyboard

Steps 4, 5 and 7 use the keyboard only. In step 5, focus must never land on the canvas body, and the loop back to the first block must not occur.

Screenshots or screencast

Before (trunk, Chromium). Recording played at 10× speed: 10 Tab presses from the "Restore" button. Focus goes Options → canvas → Heading → Removed Image → canvas body → Heading → …, and the loop repeats. The overlay at the bottom left shows each Tab press and the focused element.

rev-tab-loop-10x.webm

After (this PR, Chromium, normal speed): 10 Tab presses from the "Restore" button. Focus moves past the modified paragraph to the heading, through the list and the image, and then to the "Document changes" region.

rev-tab-after-fix.webm

Use of AI Tools

I used Claude Code for this pull request. It traced the cause, wrote the code change, the unit test, the e2e test, and this description. I reviewed the change and the test results.

New tests:

  • Unit: canHostEditableRoot returns false in preview mode.
  • e2e (revisions.spec.js): Tab moves from a paragraph to the next block, then to the "Document changes" region. A click on a paragraph, then Tab, also moves to the next block. A MutationObserver checks that the canvas body never gets contenteditable="true".

Local results (Chromium):

  • The new e2e test fails without the fix, at the Tab step, and passes with it.
  • block-editor unit tests for the store, writing flow and rich text: 658 passed.
  • multi-block-selection.spec.js, editable-root.spec.js and editable-root-compat.spec.js pass, except "should keep correct selection when dragging outside block". That test fails in the same way without this change.

In the revisions screen, when a Paragraph or List Item block was focused by Tab or clicked, the canvas body became an editing host and took focus. In Chromium, the next Tab then went back to the first block, so keyboard users could not reach the remaining blocks or the "Document changes" region. canHostEditableRoot now returns false in preview mode. This stops both useEditableRoot and useSelectionObserver from enabling the editing host.
@mattcowan
mattcowan requested a review from ellatrix as a code owner October 12, 2026 17:42
@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Oct 12, 2026
@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

👋 Welcome

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @mattcowan! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

🎉 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: mattcowan <matthewneilcowan@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@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.

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Oct 12, 2026
@mattcowan mattcowan mentioned this pull request Oct 14, 2026
11 of 19 tasks
@joedolson joedolson added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Feature] History History, undo, redo, revisions, autosave. labels Oct 14, 2026
…iew-editable-root

# Conflicts:
#	packages/block-editor/CHANGELOG.md
#	packages/block-editor/src/store/test/private-selectors.ts
…iew-editable-root

# Conflicts:
#	packages/block-editor/CHANGELOG.md
…iew-editable-root

# Conflicts:
#	packages/block-editor/CHANGELOG.md
@ellatrix ellatrix added the [Type] Bug An existing feature does not function as intended label Nov 10, 2026
# Conflicts:
#	packages/block-editor/CHANGELOG.md
@ellatrix ellatrix added the Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Nov 10, 2026

@Mamaduka Mamaduka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preparing next beta sync for WP. Going to merge this. Thanks, @mattcowan!

@Mamaduka Mamaduka added the props-bot Manually triggers Props Bot to ensure the list of props is up to date. label Nov 10, 2026
@github-actions github-actions Bot removed the props-bot Manually triggers Props Bot to ensure the list of props is up to date. label Nov 10, 2026
@Mamaduka
Mamaduka merged commit afa78ba into WordPress:trunk Nov 10, 2026
122 of 125 checks passed
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 10, 2026
@github-actions

Copy link
Copy Markdown

There was a conflict while trying to cherry-pick the commit to the wp/7.2 branch. Please resolve the conflict manually and create a PR to the wp/7.2 branch.

PRs to wp/7.2 are similar to PRs to trunk, but you should base your PR on the wp/7.2 branch instead of trunk.

# Checkout the wp/7.2 branch instead of trunk.
git checkout wp/7.2

# Create a new branch for your PR.
git checkout -b my-branch

# Cherry-pick the commit.
git cherry-pick afa78bad5ba340ab8a8e1cd69cafc8dc716c2f7d

# Check which files have conflicts.
git status

# Resolve the conflict...
# Add the resolved files to the staging area.
git status
git add .
git cherry-pick --continue

# Push the branch to the repository
git push origin my-branch

# Create a PR and set the base to the wp/7.2 branch.
# See https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request.

@Mamaduka Mamaduka added Backported to WP Core Pull request that has been successfully merged into WP Core and removed Backport to WP 7.2 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta labels Nov 10, 2026
Mamaduka added a commit that referenced this pull request Nov 10, 2026
)

Co-authored-by: mattcowan <matthewneilcowan@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
wporg-sync pushed a commit to WordPress/wordpress-develop that referenced this pull request Nov 10, 2026
This updates the pinned commit hash of the Gutenberg repository from `c035c1a649ef68f5c1646694cf440df1d7ae6e62` to `1b0dc90c700746b108e080263a4dc67707b750a1` (fixes cherry-picked to the `wp/7.2` branch).

A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@c035c1a...1b0dc90

- [WP 7.2] Components, UI: Use focus-visible for disabled item focus rings (WordPress/gutenberg#86269)
- Notes: Keep the canvas still when a new note is added (WordPress/gutenberg#86283) (#86293)
- Post summary: Show placeholders for an empty excerpt and a missing author (WordPress/gutenberg#85842) (#86294)
- Core fields: Restore the previous Publish and Status panel date behaviour (WordPress/gutenberg#86065) (#86295)
- Interactivity API: Show the data-wp-html fallback on created elements under Trusted Types (WordPress/gutenberg#84924) (#86306)
- [WP 7.2] UI: Add LoadingIndicator to item popups (WordPress/gutenberg#86303)
- Interactivity Router: Fix nested router regions without data-wp-interactive disappearing on navigation (WordPress/gutenberg#86061) (#86308)
- Interactivity API: Run watch() cleanups and attachTo render callbacks without a directive scope (WordPress/gutenberg#86058) (#86311)
- DataForm: Fix clipped focus ring of field values in panel layout (WordPress/gutenberg#86361) (#86369)
- Tests: Avoid passing an object when invoking static methods via reflection. (WordPress/gutenberg#86329)
- [WP 7.2] DropdownMenu: Invert the selected item indicator while highlighted (WordPress/gutenberg#86379)
- Fields: Lowercase the (no excerpt), (no author) and (no description) placeholders (WordPress/gutenberg#86391) (#86424)
- Core fields: Decode non-Latin slugs in the slug field (WordPress/gutenberg#86359)
- Interactivity API: Show the new page's server content in kept data-wp-html elements (WordPress/gutenberg#86416)
- DataForm: Tighten value density in the panel layout (WordPress/gutenberg#86389) (#86426)
- Post summary: Show "Immediately" and relative publish dates in the Date row (WordPress/gutenberg#86367)
- [WP 7.2] Block Styles: Show the active style variation in forced colors mode (WordPress/gutenberg#86450)
- Site Editor: Fix the frame snapping to the mobile width when resized with the mouse (WordPress/gutenberg#86423)
- Image: measure the lightbox container, not the image's parent (WordPress/gutenberg#82312) (#85491)
- URL: Decode percent-encoded characters in getFilename (WordPress/gutenberg#86422) (#86477)
- Fix: Hide the author avatar when the site does not show avatars and frame a blank one. (WordPress/gutenberg#86395)
- Date picker: Mark the posts of the month a typed or reset date moves to (WordPress/gutenberg#86298) (#86463)
- Fix iOS 27 tap into a heading leaving the caret in a quote (WordPress/gutenberg#85809)
- Hand focus back to the field on a press in every browser (WordPress/gutenberg#86549)
- Prevent jobs from running within forks on `push`. (WordPress/gutenberg#85968)
- i18n: Add translator context to the "Copy error" button label (WordPress/gutenberg#85967)
- Bubble editor canvas events to the outer iframe (WordPress/gutenberg#85263)
- UI: Use LoadingIndicator in remaining popup consumers (WordPress/gutenberg#86501)
- Block Editor: Keep the revision canvas read-only in preview mode (WordPress/gutenberg#84578)
- Core Data: Rank an exact title match first among tied link suggestions (WordPress/gutenberg#86327)
- Tests: Render the router-html-server context case through state (WordPress/gutenberg#86511)
- iOS tests: De-flake the selection handle test (WordPress/gutenberg#85461)

Props mamaduka, wildworks.
See #66340.

git-svn-id: https://develop.svn.wordpress.org/trunk@65379 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Nov 10, 2026
This updates the pinned commit hash of the Gutenberg repository from `c035c1a649ef68f5c1646694cf440df1d7ae6e62` to `1b0dc90c700746b108e080263a4dc67707b750a1` (fixes cherry-picked to the `wp/7.2` branch).

A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@c035c1a...1b0dc90

- [WP 7.2] Components, UI: Use focus-visible for disabled item focus rings (WordPress/gutenberg#86269)
- Notes: Keep the canvas still when a new note is added (WordPress/gutenberg#86283) (#86293)
- Post summary: Show placeholders for an empty excerpt and a missing author (WordPress/gutenberg#85842) (#86294)
- Core fields: Restore the previous Publish and Status panel date behaviour (WordPress/gutenberg#86065) (#86295)
- Interactivity API: Show the data-wp-html fallback on created elements under Trusted Types (WordPress/gutenberg#84924) (#86306)
- [WP 7.2] UI: Add LoadingIndicator to item popups (WordPress/gutenberg#86303)
- Interactivity Router: Fix nested router regions without data-wp-interactive disappearing on navigation (WordPress/gutenberg#86061) (#86308)
- Interactivity API: Run watch() cleanups and attachTo render callbacks without a directive scope (WordPress/gutenberg#86058) (#86311)
- DataForm: Fix clipped focus ring of field values in panel layout (WordPress/gutenberg#86361) (#86369)
- Tests: Avoid passing an object when invoking static methods via reflection. (WordPress/gutenberg#86329)
- [WP 7.2] DropdownMenu: Invert the selected item indicator while highlighted (WordPress/gutenberg#86379)
- Fields: Lowercase the (no excerpt), (no author) and (no description) placeholders (WordPress/gutenberg#86391) (#86424)
- Core fields: Decode non-Latin slugs in the slug field (WordPress/gutenberg#86359)
- Interactivity API: Show the new page's server content in kept data-wp-html elements (WordPress/gutenberg#86416)
- DataForm: Tighten value density in the panel layout (WordPress/gutenberg#86389) (#86426)
- Post summary: Show "Immediately" and relative publish dates in the Date row (WordPress/gutenberg#86367)
- [WP 7.2] Block Styles: Show the active style variation in forced colors mode (WordPress/gutenberg#86450)
- Site Editor: Fix the frame snapping to the mobile width when resized with the mouse (WordPress/gutenberg#86423)
- Image: measure the lightbox container, not the image's parent (WordPress/gutenberg#82312) (#85491)
- URL: Decode percent-encoded characters in getFilename (WordPress/gutenberg#86422) (#86477)
- Fix: Hide the author avatar when the site does not show avatars and frame a blank one. (WordPress/gutenberg#86395)
- Date picker: Mark the posts of the month a typed or reset date moves to (WordPress/gutenberg#86298) (#86463)
- Fix iOS 27 tap into a heading leaving the caret in a quote (WordPress/gutenberg#85809)
- Hand focus back to the field on a press in every browser (WordPress/gutenberg#86549)
- Prevent jobs from running within forks on `push`. (WordPress/gutenberg#85968)
- i18n: Add translator context to the "Copy error" button label (WordPress/gutenberg#85967)
- Bubble editor canvas events to the outer iframe (WordPress/gutenberg#85263)
- UI: Use LoadingIndicator in remaining popup consumers (WordPress/gutenberg#86501)
- Block Editor: Keep the revision canvas read-only in preview mode (WordPress/gutenberg#84578)
- Core Data: Rank an exact title match first among tied link suggestions (WordPress/gutenberg#86327)
- Tests: Render the router-html-server context case through state (WordPress/gutenberg#86511)
- iOS tests: De-flake the selection handle test (WordPress/gutenberg#85461)

Props mamaduka, wildworks.
See #66340.
Built from https://develop.svn.wordpress.org/trunk@65379


git-svn-id: http://core.svn.wordpress.org/trunk@64518 1a063a9b-81f0-0310-95a4-ce76da25c4cd
arshidkv12 pushed a commit to arshidkv12/wordpress-develop that referenced this pull request Nov 21, 2026
This updates the pinned commit hash of the Gutenberg repository from `c035c1a649ef68f5c1646694cf440df1d7ae6e62` to `1b0dc90c700746b108e080263a4dc67707b750a1` (fixes cherry-picked to the `wp/7.2` branch).

A full list of changes included in this commit can be found on GitHub: WordPress/gutenberg@c035c1a...1b0dc90

- [WP 7.2] Components, UI: Use focus-visible for disabled item focus rings (WordPress/gutenberg#86269)
- Notes: Keep the canvas still when a new note is added (WordPress/gutenberg#86283) (#86293)
- Post summary: Show placeholders for an empty excerpt and a missing author (WordPress/gutenberg#85842) (#86294)
- Core fields: Restore the previous Publish and Status panel date behaviour (WordPress/gutenberg#86065) (#86295)
- Interactivity API: Show the data-wp-html fallback on created elements under Trusted Types (WordPress/gutenberg#84924) (#86306)
- [WP 7.2] UI: Add LoadingIndicator to item popups (WordPress/gutenberg#86303)
- Interactivity Router: Fix nested router regions without data-wp-interactive disappearing on navigation (WordPress/gutenberg#86061) (#86308)
- Interactivity API: Run watch() cleanups and attachTo render callbacks without a directive scope (WordPress/gutenberg#86058) (#86311)
- DataForm: Fix clipped focus ring of field values in panel layout (WordPress/gutenberg#86361) (#86369)
- Tests: Avoid passing an object when invoking static methods via reflection. (WordPress/gutenberg#86329)
- [WP 7.2] DropdownMenu: Invert the selected item indicator while highlighted (WordPress/gutenberg#86379)
- Fields: Lowercase the (no excerpt), (no author) and (no description) placeholders (WordPress/gutenberg#86391) (#86424)
- Core fields: Decode non-Latin slugs in the slug field (WordPress/gutenberg#86359)
- Interactivity API: Show the new page's server content in kept data-wp-html elements (WordPress/gutenberg#86416)
- DataForm: Tighten value density in the panel layout (WordPress/gutenberg#86389) (#86426)
- Post summary: Show "Immediately" and relative publish dates in the Date row (WordPress/gutenberg#86367)
- [WP 7.2] Block Styles: Show the active style variation in forced colors mode (WordPress/gutenberg#86450)
- Site Editor: Fix the frame snapping to the mobile width when resized with the mouse (WordPress/gutenberg#86423)
- Image: measure the lightbox container, not the image's parent (WordPress/gutenberg#82312) (#85491)
- URL: Decode percent-encoded characters in getFilename (WordPress/gutenberg#86422) (#86477)
- Fix: Hide the author avatar when the site does not show avatars and frame a blank one. (WordPress/gutenberg#86395)
- Date picker: Mark the posts of the month a typed or reset date moves to (WordPress/gutenberg#86298) (#86463)
- Fix iOS 27 tap into a heading leaving the caret in a quote (WordPress/gutenberg#85809)
- Hand focus back to the field on a press in every browser (WordPress/gutenberg#86549)
- Prevent jobs from running within forks on `push`. (WordPress/gutenberg#85968)
- i18n: Add translator context to the "Copy error" button label (WordPress/gutenberg#85967)
- Bubble editor canvas events to the outer iframe (WordPress/gutenberg#85263)
- UI: Use LoadingIndicator in remaining popup consumers (WordPress/gutenberg#86501)
- Block Editor: Keep the revision canvas read-only in preview mode (WordPress/gutenberg#84578)
- Core Data: Rank an exact title match first among tied link suggestions (WordPress/gutenberg#86327)
- Tests: Render the router-html-server context case through state (WordPress/gutenberg#86511)
- iOS tests: De-flake the selection handle test (WordPress/gutenberg#85461)

Props mamaduka, wildworks.
See #66340.

git-svn-id: https://develop.svn.wordpress.org/trunk@65379 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backported to WP Core Pull request that has been successfully merged into WP Core [Feature] History History, undo, redo, revisions, autosave. First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Visual revisions: let Tab move past paragraphs in the revision canvas

4 participants