-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Rich text: useAnchor: remove value dependency #48715
Conversation
editableContentElement, | ||
activeFormat, | ||
value.start, | ||
value.end, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously we also got the following warning:
React Hook useMemo has unnecessary dependencies: 'value.end' and 'value.start'. Either exclude them or remove the dependency array.
074d048
to
367682a
Compare
Size Change: +154 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
Flaky tests detected in 288a9ed. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4327120187
|
80aa16e
to
be39d22
Compare
e1166c8
to
588cfcb
Compare
What?
useAnchor
depends onvalue
, which is actually only used to recalculate derived data from the DOM selection. Instead of usingvalue
to trigger recalculations, this PR adds a subscription to only selection changes.Why?
useAnchor
currently depends onvalue
, which blocks us from making further performance improvements, more specifically avoiding re-renders of RichText UI on typing. See #48460 (comment).Additionally the API also becomes simpler to use.
How?
Local state.
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast