Refactor useEventHandlers to use Callback Ref.#28658
Closed
ntsekouras wants to merge 1 commit intomasterfrom
Closed
Refactor useEventHandlers to use Callback Ref.#28658ntsekouras wants to merge 1 commit intomasterfrom
ntsekouras wants to merge 1 commit intomasterfrom
Conversation
|
Size Change: +9 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
Member
|
I believe we are having a similar issue, as we get a js error on focus that is triggered by null value on I believe there check for will fix our issue as well. |
Contributor
Author
Hey - you mean on master or on this branch? Because this branch will need many related checks in
|
Member
In master and in WP 5.6 |
6 tasks
Contributor
Author
|
closing in favor of: #28917 |
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.
Description
This PR will refactor
useEventHandlersto use Callback Ref.The current code has a problematic behaviour on blocks like
Latest Posts, that change theirref, based on some conditions (ex wait for a request). InsideuseBlockProps, that is callinguseEventHandlers, we assign aonFocushandler for the first ref. Later when therefchanges, theonFocushandler hasn't been attached....This happens because the
ref.currentdoesn't trigger a rerender when it changes.Related issues: #28417, #28880
This is not working currently as there is more work to be done
refinuseBlockProps.RichTextcomponent work, as it expects ref.current to be always set, but with Callback Ref it can be null on first render.