-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Refactor useEventHandlers to use Callback Ref. #28658
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
Conversation
|
Size Change: +9 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
|
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. |
Hey - you mean on master or on this branch? Because this branch will need many related checks in
|
In master and in WP 5.6 |
|
closing in favor of: #28917 |
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.