Skip to content

E2E: Add regression test for multi-block Rich Text tabindex - #78073

Merged
ntsekouras merged 3 commits into
WordPress:trunkfrom
annezazu:add/e2e-test-multi-block-tabindex-regression
Nov 14, 2026
Merged

ntsekouras merged 3 commits into
WordPress:trunkfrom
annezazu:add/e2e-test-multi-block-tabindex-regression

Conversation

@annezazu

@annezazu annezazu commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

What?

Adds an end-to-end regression test in test/e2e/specs/editor/various/multi-block-selection.spec.js that asserts Rich Text elements inside multi-selected blocks do not carry a tabindex attribute.

Verifies that #53774 stays fixed.

Why?

Per @ellatrix's request in #53774, the original fix was an "accidental" side effect of #53440 (and earlier discussion in #53799), so an e2e test guards against accidental regression.

The bug, in short: Rich Text elements inside multi-selected blocks used to have tabindex="0". Browsers (Safari especially) would move focus to a Rich Text element on shift-click or right-click into a multi-selected block. Once focus landed on the Rich Text, cut / copy events were handled by the single-block Rich Text handler instead of the global multi-block handler — only one block ended up copied, sometimes with a Failed to execute 'insertBefore' on 'Node' React reconciliation error.

The fix removes tabIndex from contentEditable Rich Text in packages/block-editor/src/components/rich-text/index.js.

How?

The test:

  1. Inserts three paragraph blocks.
  2. Multi-selects them with Ctrl/Cmd+A twice.
  3. Asserts each Block: Paragraph element has no tabindex attribute.
  4. Confirms the end-to-end consequence: copy → backspace → paste round-trips all three blocks (not just one).

The test was confirmed to fail when the tabIndex override in rich-text/index.js is reverted, and pass with the override in place — across Chromium, Firefox, and WebKit.

Testing Instructions

npm run wp-env-test -- start
npm run test:e2e -- test/e2e/specs/editor/various/multi-block-selection.spec.js --grep "should not assign tabindex"

Expected: 3 passed (chromium, firefox, webkit).

To verify the test catches regressions, temporarily replace the tabIndex block in packages/block-editor/src/components/rich-text/index.js with tabIndex={ props.tabIndex }, rebuild (npm run build), and re-run — the test should fail with <p tabindex="0" ... is-multi-selected>.

Testing Instructions for Keyboard

No UI changes; this PR only adds an automated test.

Summary by CodeRabbit

  • Tests
    • Added end-to-end coverage for selecting multiple paragraph blocks in the Rich Text editor.
    • Verified that multi-selected Rich Text elements do not receive a tabindex.
    • Confirmed copying, deleting, and pasting preserves all selected blocks.

@annezazu
annezazu requested a review from ellatrix May 7, 2026 22:57
@annezazu annezazu added the [Package] E2E Tests /packages/e2e-tests label May 7, 2026
@t-hamano t-hamano added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Feature] Paste and removed [Package] E2E Tests /packages/e2e-tests labels May 8, 2026
@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 46c4e3b6-2c45-44c4-8bc2-5d2577f14872

📥 Commits

Reviewing files that changed from the base of the PR and between 19126f1 and e1066b4.

📒 Files selected for processing (1)
  • test/e2e/specs/editor/various/multi-block-selection.spec.js

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

Adds an end-to-end regression test for multi-selected paragraph blocks. The test checks tabindex attributes and verifies that copy, delete, and paste preserve all selected blocks.

Changes

Multi-block selection

Layer / File(s) Summary
Multi-block selection regression test
test/e2e/specs/editor/various/multi-block-selection.spec.js
Adds coverage for three selected paragraph blocks. The test verifies that Rich Text elements have no tabindex and that copy, delete, and paste preserve all blocks.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to e1066

This adds regression coverage for multi-block selection copy, delete, and paste behavior without changing product runtime code. No current merge-readiness risk remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding an end-to-end regression test for multi-block Rich Text tabindex behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

// block ends up copied, with a possible React reconciliation error).
// This test MUST fail if the `tabIndex` override in
// packages/block-editor/src/components/rich-text/index.js is removed.
test( 'should not assign tabindex to Rich Text within multi-selected blocks', async ( {

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.

I don't think these were the steps of #53774. That issue was about a partial selection of paragraphs? Pressing cmd+a will trigger a "full" selection (whole blocks colored, vs a text selection. Also this test seems to do a copy instead of a cut.

@ntsekouras ntsekouras Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ellatrix I updated it to use a partial selection of paragraphs. I didn't add the cut since partial cut is already covered in copy-cut-paste.spec.js. The tabindex check is what fails if this regresses. What do you think?

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.

I think that's testing implementation details. We should test the steps in the original issue. I pushed a change, how does that look?

Adds an e2e test that asserts Rich Text elements inside multi-selected
blocks do not carry a `tabindex` attribute. Without the `tabIndex`
override in `packages/block-editor/src/components/rich-text/index.js`,
browsers (Safari especially) move focus to a Rich Text on shift-click
or right-click into a multi-selected block, which routes copy/cut
events to the single-block Rich Text handler instead of the global
multi-block one — only one block ends up copied, sometimes with a React
reconciliation error.

Verifies WordPress#53774 stays fixed; the test was confirmed to fail when the
`tabIndex` override is reverted, then pass again with it restored.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ntsekouras
ntsekouras force-pushed the add/e2e-test-multi-block-tabindex-regression branch from e1066b4 to b56dd01 Compare November 12, 2026 16:41
@github-actions

Copy link
Copy Markdown

🤖 PR meta 🤖

🎉 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: annezazu <annezazu@git.wordpress.org>
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@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.

…ction

Follow the steps of WordPress#53774: a partial selection of paragraphs instead of a full Cmd+A selection. Drop the copy and paste round trip, which passes even with the tabindex restored because keyboard shortcuts never move focus, and point the comment at the current rich-text/index.tsx lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ntsekouras
ntsekouras force-pushed the add/e2e-test-multi-block-tabindex-regression branch from b56dd01 to 4dcd6c5 Compare November 12, 2026 17:01
The bug in WordPress#53774 needs a right-click: it moved focus or the selection
before Cut ran. Without the right-click, cut works even when the fix is
removed. Check the cut result instead of the `tabindex` attribute.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ntsekouras
ntsekouras merged commit 3f15c50 into WordPress:trunk Nov 14, 2026
87 checks passed
@github-actions github-actions Bot added this to the Gutenberg 24.5 milestone Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Paste [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants