Skip to content
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][lexical-playground] Bug Fix: Allow setEditorState to work correctly inside of an update #6876

Merged
merged 5 commits into from
Nov 30, 2024

Conversation

etrepum
Copy link
Collaborator

@etrepum etrepum commented Nov 27, 2024

Description

LexicalEditor.setEditorState has a bunch of shared code with LexicalEditor.update such that it doesn't need to be issued from inside of an update. However, if it is issued inside of an update then it will cause an extra $commitPendingUpdates call after the state and selection are already read-only which will throw in some situations when node transforms are in use.

This fix ensures that setEditorState is working with a writable state and selection so that transforms can run, and skips the redundant $commitPendingUpdates call for the scenarios when it is being called from inside an existing update context (e.g. a dispatchCommand from the history plugin)

Closes #6843

Test plan

Before

autocomplete-undo.mov

After

autocomplete-undo-after.mov

Copy link

vercel bot commented Nov 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2024 7:44am
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2024 7:44am

@facebook-github-bot 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 Nov 27, 2024
Copy link

github-actions bot commented Nov 27, 2024

size-limit report 📦

Path Size
lexical - cjs 30.92 KB (0%)
lexical - esm 30.83 KB (0%)
@lexical/rich-text - cjs 39.73 KB (0%)
@lexical/rich-text - esm 32.65 KB (0%)
@lexical/plain-text - cjs 38.32 KB (0%)
@lexical/plain-text - esm 29.93 KB (0%)
@lexical/react - cjs 41.46 KB (0%)
@lexical/react - esm 34 KB (0%)

@etrepum etrepum changed the title [lexical][lexical-history][lexical-playground] Bug Fix: Allow setEditorState to work correctly inside of an update [lexical][lexical-playground] Bug Fix: Allow setEditorState to work correctly inside of an update Nov 27, 2024
@potatowagon potatowagon added this pull request to the merge queue Nov 30, 2024
Merged via the queue into facebook:main with commit 8e0e300 Nov 30, 2024
40 checks passed
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
Projects
None yet
3 participants