-
Notifications
You must be signed in to change notification settings - Fork 4.7k
ToolsPanel: Allow items to register when panelId is null #37273
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: +25 B (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
andrewserong
left a comment
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 is looking good to me @aaronrobertshaw! The logic of rendering the ToolsPanelItem when the ToolsPanel is null looks clear, the added test makes good sense, and I couldn't find any issues testing this in isolation or with it rebased on top of #37216 — tested with a mix of paragraph, heading and columns blocks, and switching between different blocks with a variety of settings.
LGTM!
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 🚀
(and special thanks for updating tests and docs!)
This helps make the ToolsPanel compatible for use when multiple blocks are selected and the original approach setting the panelId as the block's clientId cannot work.
806b842 to
073087f
Compare
|
I've had to refine the logic around panel item registration and deregistration. The changes effectively tighten up when this occurs, specifically so that selecting multiple blocks in reverse order doesn't cause attributes to be reset. The unit tests were extended to cover this edge case. A new test ensuring orphaned panel items don't occur was also added. |
andrewserong
left a comment
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.
Nice work refining the logic @aaronrobertshaw and thanks for adding in the test to check for orphaned panel items, that all looks good to me.
Just re-tested and it's still working well:
✅ Tests pass and all Storybook examples still work well
✅ Featured Image block's conditionally rendered scale control works
✅ Test that injected controls do not persist between block selections (did lots of switching between blocks, e.g. Cover to Group to Post Featured Image
✅ Tested multiple block selection within block editor with this PR rebased on #37216
LGTM! 🎉
|
As this is required for the regression fix for multi-selections and the typography block support I've added the backport label to this as well. See #37216 (comment) |
)" This reverts commit 4ada4e7.
This helps make the ToolsPanel compatible for use when multiple blocks are selected and the original approach setting the panelId as the block's clientId cannot work.
Related:
Description
When multiple blocks are selected the
panelIdapplied to theToolsPanelisnull. This PR updates the checks restricting panel item registration to allow them to register in this scenario.Changes include:
ToolsPanelItemhookHow has this been tested?
npm run test-unit packages/components/src/tools-panel/testTypes of changes
Bug fix.
Checklist:
*.native.jsfiles for terms that need renaming or removal).