-
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
Fix block ref when multiple useBlockProps hooks are called #31906
Conversation
Size Change: +7 B (0%) Total Size: 1.62 MB
ℹ️ View Unchanged
|
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.
I tested with Featured Image and if I apply an align
it doesn't show the toolbar.
packages/block-editor/src/components/block-list/use-block-props/use-block-refs.js
Show resolved
Hide resolved
5a39d56
to
c7d2c38
Compare
Does it work now? :) |
Hm, it looks like its still disappears, but then shows when you reselect. I'll check what's going wrong. |
It works for me and can't reproduce the above issue.. 🤔 |
It should be fixed now. |
Oops. Should be fixed now. |
51b871b
to
91ea462
Compare
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.
This works for me in both site and post editor. Thanks!
91ea462
to
a07718b
Compare
Description
If multiple
useBlockProps()
are called for a single block, currently we only look at the ref of the last call because all previous refs would be overridden (refs are stored by client ID). The solution is to store refs by ref instead and allow multiple refs to be stored for one client ID. When we need the ref, we can check which one is set.How has this been tested?
Screenshots
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).