Repository navigation
Rich text: useAnchor: remove value dependency - #48715
Merged
Merged
Conversation
ellatrix
commented
Mar 3, 2023
Member
Author
There was a problem hiding this comment.
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.
ellatrix
force-pushed
the
remove/use-anchor-value-dependency
branch
from
March 3, 2023 11:03
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
|
ellatrix
force-pushed
the
remove/use-anchor-value-dependency
branch
from
March 3, 2023 12:27
80aa16e to
be39d22
Compare
ellatrix
force-pushed
the
remove/use-anchor-value-dependency
branch
from
March 3, 2023 20:33
e1166c8 to
588cfcb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
useAnchordepends onvalue, which is actually only used to recalculate derived data from the DOM selection. Instead of usingvalueto trigger recalculations, this PR adds a subscription to only selection changes.Why?
useAnchorcurrently 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