-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Breaking Change][lexical][lexical-playground] Bug Fix: Improve character deletion around shadow roots and decorators #7155
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…st table in the editor
return false; | ||
} | ||
if (!isBackward) { | ||
// inherit strange forward delete behavior per e2e election test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to change the behaviour that forward deletion should not delete the collapsible section, I'm with you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have strong opinions about it, it's in a playground plug-in after all. I figured that breaking zero tests would maybe speed up review but it's been a week 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make it better. I'll do my part on the reviewing side this evening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a follow-up #7203 to address this separately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR in #7204
if (target) { | ||
if ($isLineBreakNode(possibleLineBreak)) { | ||
possibleLineBreak.remove(); | ||
} | ||
target.select().insertRawText(textContent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come this toolbar logic has now become so manual? Is this the final shape? It used to be pretty straightforward to replicate once it was backed by insertNodes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because insertNodes is buggy and I didn't want to also fix that in the scope of this PR
Breaking Change
The heuristic used in
RangeSelection.deleteCharacter
to handle merging blocks and deleting decorators from a collapsed selection has been refactored for consistency. It now traverses the node tree directly instead of attempting to use browser selection APIs.This generally has much more predictable results, aligned with how this method is expected to behave, but it is not "bug for bug" compatible with how it worked previously. Notably, it will no longer pierce shadow roots when merging blocks. For example, performing a forward deletion from the end of a block before a
CollapsibleContainerNode
would pierce the shadow root of itsCollapsibleTitleNode
and merge its first block child (e.g. the preceding paragraph and the title's paragraph would be merged). Since there was a test that expected this strange behavior, this functionality was moved to theCollapsiblePlugin
'sDELETE_CHARACTER_COMMAND
command listener.Description
Allowing the native platform to control deletion only really makes sense when the content to be deleted includes a TextNode, otherwise we are better off handling it ourselves. There's also some "interesting" edge cases around nested elements (with or without shadow roots) and decorators that need to be addressed by this sort of manual navigation.
Other fixes:
$setBlocksType
workaround for code nodes (playground only) Bug: Unexpected behavior with transform selected lines to code block #5686$setBlocksType
support for selection types other than RangeSelection Bug: Block Type Change to Normal Fails for Selected Table Cells in Playground #7082selection.removeText()
toRangeSelection.insertNodes(…)
Closes #7082
Closes #7090
Closes #5686
Closes #7173
Closes #6763
Closes #7184
Test plan
Before
After