-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[lexical] Bug Fix: TextNode in token mode should not be split by removeText #6690
[lexical] Bug Fix: TextNode in token mode should not be split by removeText #6690
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
ea1aab1
to
cd50c99
Compare
b99a11e
to
55ae953
Compare
Appreciate the proposed changes and prefer this approach. Since I didn’t have the chance to follow up with tests earlier and you seem to have everything covered, I’ve gone ahead and closed my PR in favour of this one. That said, I do have a suggestion: it might be worth updating the |
I don't think it's really worth the code churn to change I do wonder if this makes sense at all since it seems that the logic to handle segmented deletion is elsewhere but if this better matches the previous behavior then it probably is the right thing to do. |
Just to be clear, I only talk about replacing Making the exclusion explicit avoids potential confusion. |
@@ -344,6 +344,295 @@ describe('LexicalSelection tests', () => { | |||
}); | |||
}); | |||
describe('removeText', () => { | |||
describe('with a leading TextNode and a trailing token TextNode', () => { |
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.
thanks for adding a test case
Description
The #6456 removeText rewrite introduced a regression in token mode behavior where it behaved too similarly to segmented nodes, it would be split and replaced with a plain TextNode instead of being deleted in full. This takes the simple approach of just expanding the selection outwards if the focus or anchor node contains any content from a token node.
Closes #6687
Test plan
Before
There were no tests to show that token TextNode should be deleted in full by removeText
After
Now there are tests that cover removeText behavior for token TextNode