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] Bug Fix: getCachedTypeToNodeMap should handle a empty and writable EditorState #6444

Merged

Conversation

etrepum
Copy link
Collaborator

@etrepum etrepum commented Jul 22, 2024

Description

Follow-up to #6357

When an editor is still initializing the this._editorState may be writable but will only have the 'root' entry. We need to special case this to prevent an exception if a mutation listener with initialization is registered before the first reconciliation.

Test plan

The unit test covers this case and will fail without the change

Copy link

vercel bot commented Jul 22, 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 Jul 22, 2024 11:01pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 22, 2024 11:01pm

@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 Jul 22, 2024
Copy link

size-limit report 📦

Path Size
lexical - cjs 28.86 KB (0%)
lexical - esm 28.73 KB (0%)
@lexical/rich-text - cjs 37.24 KB (0%)
@lexical/rich-text - esm 28.18 KB (0%)
@lexical/plain-text - cjs 35.85 KB (0%)
@lexical/plain-text - esm 25.49 KB (0%)
@lexical/react - cjs 39.14 KB (0%)
@lexical/react - esm 29.62 KB (0%)

@etrepum etrepum marked this pull request as ready for review July 23, 2024 00:02
@@ -903,7 +903,7 @@ export class LexicalEditor {
klass: Klass<LexicalNode>,
): void {
const prevEditorState = this._editorState;
const nodeMap = getCachedTypeToNodeMap(this._editorState).get(
const nodeMap = getCachedTypeToNodeMap(prevEditorState).get(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a meaningful change but should optimize better

@zurfyx zurfyx added this pull request to the merge queue Jul 23, 2024
Merged via the queue into facebook:main with commit 14c63f6 Jul 23, 2024
38 of 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants