[Selection] keep image selection when 'selectionchange' range is collapsed#3396
Open
liangdrime wants to merge 1 commit into
Open
[Selection] keep image selection when 'selectionchange' range is collapsed#3396liangdrime wants to merge 1 commit into
liangdrime wants to merge 1 commit into
Conversation
Contributor
Author
The The fix is simple: updates |
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.
Summary
This change is to prevent
SelectionPluginfrom converting an image selection into a range selection when the browser reports a collapsed range during "selectionchange".Issue
The logic for converting image selection to a range was first introduced in #2566. According to its description, this change was intended to correct the selection to a range when it expands to cover a wider area, such as when triggered by keyboard shortcuts like Ctrl+A.
However, on Mac, right-clicking an image while it is in editing mode converts the collapsed image selection to a range selection, causing the subsequent 'Crop' action from the context menu to fail.
onSelectionChangecurrently converts image selection to range wheneverisSingleImageInSelection(range)returns null.For collapsed ranges, that helper correctly returns null, but this was treated as a wider-range transition and caused an unintended downgrade from image selection to collapsed range selection.
Fix
The intended conversion is for wider range transitions only. A collapsed range is an empty caret state, not a wider selection, so converting image selection in that case is not semantically correct and causes product regressions.
So, this change updated
SelectionPlugin.onSelectionChangeand image to range conversion only happens when the current range is not collapsed.