Repository navigation
[lexical-rich-text] Bug Fix: extend adjacent node selections with Shift+Arrow - #9067
Merged
Merged
Conversation
…ft+Arrow ## Description The arrow-key handlers collapsed a `NodeSelection` before checking `shiftKey`, so Shift+Arrow moved the caret away from a selected decorator instead of extending the selection. This converts a `NodeSelection` to a `RangeSelection` when it contains one node or contiguous siblings, then extends the range in the requested direction. Discontiguous node selections keep the existing collapse behavior because a range would also select the nodes between them. Closes meta#9062 ## Test plan ### Before ```text vitest --run packages/lexical-rich-text/src/__tests__/unit/RichTextNodeSelectionArrow.test.ts Test Files 1 failed (1) Tests 5 failed | 1 passed (6) ``` ### After ```text vitest --run packages/lexical-rich-text/src/__tests__/unit Test Files 16 passed (16) Tests 141 passed (141) VITEST_BROWSER=chromium,firefox,webkit vitest --project browser --run packages/lexical-rich-text/src/__tests__/browser/RichTextNodeSelectionArrow.test.ts Test Files 3 passed (3) Tests 15 passed (15) ``` TypeScript, ESLint for the changed files, Prettier, and `git diff --check` also pass.
luantaraschi
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 13, 2026 18:43
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
If you select a decorator, pressing Shift + ArrowDown once adds the next decorator to the selection, and pressing it a second time deselects everything and moves the cursor to the end of the editor Screen.Recording.2026-08-17.at.02.56.55.movI think the expected behavior would be to select all content starting from the decorator and extending to the end of the editor |
Collaborator
|
I think that Shift+Arrow should behave exactly as if the original selection was a RangeSelection, so basically the logic is to convert NodeSelection to RangeSelection and then process the event. In the case of a discontiguous NodeSelection it should probably do nothing. I don't think this PR behaves quite correctly. |
etrepum
approved these changes
Aug 17, 2026
Merged
This branch was successfully deployed
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.
Description
The arrow-key handlers collapsed a
NodeSelectionbefore checkingshiftKey, so Shift+Arrow moved the caret away from a selected decorator instead of extending the selection.This converts a
NodeSelectionto aRangeSelectionwhen it contains one node or contiguous siblings, then extends the range in the requested direction. Discontiguous node selections keep the existing collapse behavior because a range would also select the nodes between them.Closes #9062
Test plan
Before
After
TypeScript, ESLint for the changed files, Prettier, and
git diff --checkalso pass.