Rich text: derive event handler relevance from the selection#79045
Closed
ellatrix wants to merge 2 commits into
Closed
Rich text: derive event handler relevance from the selection#79045ellatrix wants to merge 2 commits into
ellatrix wants to merge 2 commits into
Conversation
|
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. |
|
Size Change: +75 B (0%) Total Size: 8.44 MB 📦 View Changed
|
Make the copy, cut, and paste handlers check whether the current selection is within the element, instead of relying on the focused element or the event target. Behaviour is unchanged today; this keeps the handlers working when the editing host is the writing flow wrapper. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Gate the selectionchange handler on selection containment instead of the active element, so it works when the editing host is an ancestor of the element. Remove the selectionchange listener on cleanup rather than inline. Behaviour is unchanged today. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
7864803 to
f350dd4
Compare
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.
What?
Make the rich text copy, cut, paste, and selection sync handlers decide whether an event is theirs based on the current selection, instead of the focused element or the event target.
Why?
Extracted from #63671 (the reverted iOS multi-select PR): this is the behaviour-neutral, selection-driven relevance part of that change, split out on its own.
Preparation for re-enabling multi-block selection on iOS/touch. That requires the writing flow wrapper to be the editing host during selection, in which case events target the wrapper rather than the individual rich text element, so handlers keyed off
event.target/activeElementwould not fire. Keying off the selection is robust to which element is focused. No behaviour change today, since the element holding the selection is also the focused/target element.How?
element.contains( event.target ).activeElementcontainment and the record collapsed state.selectionchange): gate on selection containment instead ofactiveElement === element, and remove the listener on cleanup rather than inline.The clipboard listeners are already attached at the window level, so only the relevance check changes.
Testing Instructions
Everything should behave exactly as before.
Testing Instructions for Keyboard
As above, using Shift+Arrows to select and Ctrl/Cmd+C / X / V.
Use of AI Tools
Drafted with Claude Code (Claude Opus 4.8) and reviewed before submitting.
🤖 Generated with Claude Code