-
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 move to widget area checkmark #33213
Conversation
Size Change: +43 B (0%) Total Size: 1.05 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.
LGTM 👍
blockEditorStore | ||
); | ||
const blockParents = getBlockParents( clientId ); | ||
const widgetAreaClientId = blockParents.find( |
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.
Nitpick: Maybe we don't need to traverse all the parents because only the first non-null parent would be the widget area block?
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.
The blockParents
are ordered from top to bottom, and find
won't traverse the whole array, so I think in essence it'll be pretty much the same. It should in practice always just pick the first array element, but would still work if widget areas had a parent block (not that this will ever happen 😄 ).
Thanks for reviewing.
* Traverse through block parents to find widget area * Refactor to selector * Switch back to previous selector const * Add doc block
* Traverse through block parents to find widget area * Refactor to selector * Switch back to previous selector const * Add doc block
* Traverse through block parents to find widget area * Refactor to selector * Switch back to previous selector const * Add doc block
* Traverse through block parents to find widget area * Refactor to selector * Switch back to previous selector const * Add doc block
Description
I noticed that in
trunk
, some blocks don't have a checkmark in the Move To Widget Area dropdown to indicate which widget area they're currently in.This seems to happen to nested blocks. The feature doesn't do a deep search to find the widget area for a block. But I think there's also an issue in that only root level blocks have widget ids, and the widgetId is used to find the widget area.
In this PR I've switched it over to use the client Id and the block editor store to find the widget area for a block. I've made this a selector since the
useLastSelectedWidgetArea
hook has exactly the same requirements, and it seems like a useful API to have.How has this been tested?
Screenshots
Before
After
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
*.native.js
files for terms that need renaming or removal).