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

Clamp number of registered editor above 0 #6001

Closed
wants to merge 4 commits into from

Conversation

thegreatercurve
Copy link
Contributor

@thegreatercurve thegreatercurve commented May 1, 2024

Description

Since #5070, there are certain circumstances in which the document counts for rootElementsRegistered can fall below 0, especially if removeRootElementEvents is called more than addRemoveRootElementEvents.

As number of registered root elements should never be fewer than 1 after addRemoveRootElementEvents is called, and because the number of root elements should never be fewer than 0 when removeRootElementEvents is called, we should clamp these values.

@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 May 1, 2024
Copy link

vercel bot commented May 1, 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 May 1, 2024 8:41pm
lexical-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2024 8:41pm

Copy link

github-actions bot commented May 1, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
packages/lexical/dist/Lexical.js 23.69 KB (0%) 474 ms (0%) 494 ms (+34.45% 🔺) 968 ms
packages/lexical-rich-text/dist/LexicalRichText.js 33.99 KB (+0.23% 🔺) 680 ms (+0.23% 🔺) 1.3 s (+22.31% 🔺) 2 s
packages/lexical-plain-text/dist/LexicalPlainText.js 33.95 KB (+0.16% 🔺) 679 ms (+0.16% 🔺) 1.1 s (-17.01% 🔽) 1.8 s

acywatson
acywatson previously approved these changes May 1, 2024
@Daniel15
Copy link
Member

Daniel15 commented May 1, 2024

We should probably have an invariant rather than just clamping, so we can more easily find any bad code that causes this condition.

@thegreatercurve
Copy link
Contributor Author

Closing in favour of #6003

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.

4 participants