Fix block ref when multiple useBlockProps hooks are called#31906
Merged
youknowriad merged 3 commits intotrunkfrom May 19, 2021
Merged
Fix block ref when multiple useBlockProps hooks are called#31906youknowriad merged 3 commits intotrunkfrom
youknowriad merged 3 commits intotrunkfrom
Conversation
|
Size Change: +7 B (0%) Total Size: 1.62 MB
ℹ️ View Unchanged
|
ntsekouras
reviewed
May 18, 2021
Contributor
ntsekouras
left a comment
There was a problem hiding this comment.
I tested with Featured Image and if I apply an align it doesn't show the toolbar.
ntsekouras
reviewed
May 18, 2021
packages/block-editor/src/components/block-list/use-block-props/use-block-refs.js
Show resolved
Hide resolved
5a39d56 to
c7d2c38
Compare
Member
Author
Does it work now? :) |
Member
Author
|
Hm, it looks like its still disappears, but then shows when you reselect. I'll check what's going wrong. |
Contributor
It works for me and can't reproduce the above issue.. 🤔 |
Member
Author
|
It should be fixed now. |
Contributor
Member
Author
|
Oops. Should be fixed now. |
51b871b to
91ea462
Compare
ntsekouras
approved these changes
May 19, 2021
Contributor
ntsekouras
left a comment
There was a problem hiding this comment.
This works for me in both site and post editor. Thanks!
91ea462 to
a07718b
Compare
jffng
pushed a commit
that referenced
this pull request
May 19, 2021
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
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.jsfiles for terms that need renaming or removal).