Repository navigation
Conversation
…t+click Safari's mousedown default action focuses the nearest click-focusable element on the click path and then treats the click as caret placement, ignoring Shift and discarding the selection being extended. Rich text elements render without their tabIndex for this reason, but blocks whose wrapper is a separate element from their rich text (a list item) keep it on the wrapper, so a shift+click between list items never extended in Safari. Remove the tabIndex on mousedown and restore it when the press ends. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GQNdFF1FUU9JXfNGZev2na
|
Size Change: +132 B (0%) Total Size: 7.75 MB 📦 View Changed
|
|
Flaky tests detected in d8377d0. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/30068378544
|
|
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. |
|
Tested! Confirms the fix works as expected. Shift+click between two list items now correctly extends the text selection in real Safari on macOS, instead of just moving the caret. Environment: macOS, Safari (real browser, not Playwright's WebKit) Screen.Recording.2026-07-24.at.12.53.12.PM.mov |
What?
Fixes #80661. In Safari, shift+clicking from one list item to another extends the text selection again instead of just moving the caret.
Why?
Safari's mousedown default action focuses the nearest click-focusable element on the click path, and once it focuses something it treats the click as caret placement, ignoring Shift and discarding the selection being extended. #80651 removed the
tabIndexfrom rich text elements, which fixed blocks whose wrapper is the rich text element (paragraphs, headings). A list item's wrapper (theli) is a separate element and keepstabindex="0", so Safari still captures focus there. This is pre-existing behavior, not a regression.How?
On a cross-block shift+mousedown, remove the
tabindexfrom non-editable elements along the clicked path and restore it when the press ends (mouseup, or dragend when a native drag starts mid-press). Restoring earlier does not work: a microtask runs before the mousedown default action, so Safari would still see thetabindexwhen it captures focus (verified in real Safari). React re-renders do not resurrect the attribute mid-gesture because the rendered value is unchanged, so nothing rewrites it until the restore.Testing Instructions
Playwright's engines do not reproduce Safari's focus-capture behavior (the existing list item e2e test passes either way), so the fix is verified against real Safari via safaridriver, alongside the existing shift+click e2e suite in all three engines.
Use of AI Tools
Written with Claude Code, reviewed and tested by me.