-
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-selection][lexical-list] Bug Fix: Fix infinite loop when splitting invalid ListItemNode #7037
Merged
etrepum
merged 3 commits into
facebook:main
from
etrepum:list-item-isBlock-infinite-loop
Jan 10, 2025
Merged
[Breaking Change][lexical][lexical-selection][lexical-list] Bug Fix: Fix infinite loop when splitting invalid ListItemNode #7037
etrepum
merged 3 commits into
facebook:main
from
etrepum:list-item-isBlock-infinite-loop
Jan 10, 2025
Conversation
This file contains 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
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
facebook-github-bot
added
the
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
label
Jan 10, 2025
size-limit report 📦
|
etrepum
changed the title
[lexical][lexical-selection] Bug Fix: Fix infinite loop when splitting invalid ListItemNode
[Breaking Change][lexical][lexical-selection][lexical-list] Bug Fix: Fix infinite loop when splitting invalid ListItemNode
Jan 10, 2025
etrepum
requested review from
zurfyx,
fantactuka,
acywatson,
Fetz,
ivailop7,
Sahejkm and
potatowagon
as code owners
January 10, 2025 20:56
ivailop7
approved these changes
Jan 10, 2025
The test failure is a spurious flaky test failure, not worth running it any more times to try and get a clean run CI
Local
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
extended-tests
Run extended e2e tests on a PR
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.
Breaking Changes
insertList
andremoveList
are now deprecated, use$insertList
and$removeList
instead.INSERT_CHECK_LIST_COMMAND
,INSERT_ORDERED_LIST_COMMAND
,INSERT_UNORDERED_LIST_COMMAND
andREMOVE_LIST_COMMAND
now update synchronously when dispatched from inside an update, rather than deferring a nested update (this is the expected behavior for commands)editor.focus()
now happens synchronously when called from inside of an update, as if it was implemented with a command dispatch. Previously it would defer which is confusing behavior because the expected side-effect is to change the selection which you really do want to happen synchronously.The breaking changes are the result of trying to unit test this functionality and finding out that editor.focus and list commands are asynchronous soup for no reason. These breaking changes are unlikely to affect any correctly written code, unless it is going very far out of the way to test or otherwise compensate for the previously maddening behavior.
Description
There's a while loop in
$removeTextAndSplitBlock
that can reach a fixed point and never terminate if it reaches the root (which is not a block). This ensures that if it gets to a fixed point, the loop terminates.Additionally this fixes some incorrect code in
$setBlocksType
which mutated a potentially cachedselection.getNodes()
and did not always update the selection when it should (this was part of the preconditions for #7036) so you'd end up with a selection that is not normalized correctly that allowed you to insert TextNode adjacent to ListNode where it shouldn't be.As a small related cleanup, the
INTERNAL_$isBlock
function is now exported from thelexical
package so that it can be used in the implementation of@lexical/selection
, previously this function was copied which added unnecessary bundle size and maintenance burden to maintain two copies of this function. It's marked@internal
so the doc tools shouldn't pick it up.Closes #7036
Test plan
Before
Creating a ListItemNode that has a ListItem first child and a TextNode second child causes an infinite loop when the return key is pressed, see #7036
After
A ParagraphNode is created and it is selected. A unit test covers this addition.