Skip to content

perf(richtext-lexical): improve typing performance while toolbars are enabled #12669

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

Merged
merged 8 commits into from
Jun 5, 2025

Conversation

AlessioGr
Copy link
Member

@AlessioGr AlessioGr commented Jun 3, 2025

The lexical fixed and inline toolbars do active / enabled state calculations for toolbar buttons / dropdowns on every keystroke. This can incur a performance hit on slow machines.

This PR

  • deprioritizes these state calculations using useDeferredValue and requestIdleCallback
  • introduces additional memoization and replace unnecessary useEffects to reduce re-rendering

Before (20x cpu throttling)

Screenshot.2025-06-03.at.14.51.42.mp4

After (20x cpu throttling)

Screenshot.2025-06-03.at.14.50.01.mp4

@AlessioGr AlessioGr enabled auto-merge (squash) June 3, 2025 21:57
paulpopus
paulpopus previously approved these changes Jun 3, 2025
@AlessioGr AlessioGr requested a review from GermanJablo June 4, 2025 23:18
@AlessioGr AlessioGr merged commit aef4f77 into main Jun 5, 2025
77 checks passed
@AlessioGr AlessioGr deleted the perf/lexical-toolbars branch June 5, 2025 16:51
Copy link
Contributor

github-actions bot commented Jun 9, 2025

🚀 This is included in version v3.42.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants