Repository navigation
Fix/backspace linebreak slot boundary - #8900
Closed
sahiee-dev wants to merge 2 commits into
Closed
sahiee-dev wants to merge 2 commits into
sahiee-dev wants to merge 2 commits into
Conversation
deleteCharacter's sibling-caret exploration loop only handles ElementNode and DecoratorNode origins; a LineBreakNode falls through unhandled and reaches the trailing slot-edge boundary guard, which bails out unconditionally whenever the anchor's node is a slot value, without checking whether there is still content in the deletion direction. The LineBreakNode is left in place and backspace becomes a silent no-op. Add the missing case, mirroring the existing decorator handling: remove the LineBreakNode directly instead of falling through.
sahiee-dev
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
July 31, 2026 12:28
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
Contributor
Author
|
Closing this in favor of #8899, which now covers both fixes. Makes sense, they touch the same function family and I found this bug while verifying the other one, so it's the same investigation really. Thanks for the flag. |
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
While looking into
RangeSelection.deleteCharacter, I found an edge case in the logic that handles deletion when there is no text left in the current deletion direction.The method first walks through the node next to the caret to see if there is anything special it should handle before falling back to the generic deletion behavior. That logic currently only accounts for
ElementNodeandDecoratorNode. SinceLineBreakNodeisn't handled, it simply falls through without any action.After that comes the slot boundary guard. If the caret ends up on a slot value, the function exits immediately because slot content behaves like a virtual shadow root, and deletion shouldn't cross into the host's real DOM. The problem is that this guard only checks whether the caret is on a slot value, it doesn't verify whether there was still a node that could have been deleted first.
As a result, when a bare block slot value (such as the attribution line in a Pull Quote) ends with one or more line breaks, placing the caret at the end and pressing Backspace does nothing. The sibling-caret loop skips over the
LineBreakNode, the boundary guard returns early, and nothing gets deleted. Repeated Backspace presses continue to be silent no-ops.Fix: Add the missing
LineBreakNodecase to the sibling-caret loop, mirroring the existingDecoratorNodehandling. This allows trailing line breaks to be removed before the slot boundary guard is reached, while keeping the existing slot-boundary protection intact.Closes #8898
Test plan
Added a unit test in
packages/lexical/src/__tests__/unit/LexicalSlot.test.ts:Creates a bare block slot value ending with two trailing line breaks, performs Backspace twice, and verifies that the number of line breaks decreases from
2 → 1 → 0while leaving the text content unchanged.The new test reproduces the issue on the original code (the line break count remains at
2after pressing Backspace) and passes with the fix applied.I also ran the full Lexical core unit test suite (818 tests), and everything passed without regressions. Finally, I verified the behavior manually in the browser: repeated Backspace presses now remove one trailing line break at a time, normal character deletion behaves as expected, and the existing slot-boundary protection at the true start of the slot content still correctly prevents deletion across the boundary.
Before
Screen.Recording.2026-07-31.at.5.56.51.PM.mov
After
Screen.Recording.2026-07-31.at.5.56.09.PM.mov