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
Make the __experimentalCaptureToolbars option work reliably #28905
Conversation
Size Change: +18 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
This feels more consistent when editing Navigations with submenus. One thing I did notice was that the parent button icon changes; When I'm editing a top-level link the parent button shows the Navigation block icon, but when I select a child of a top-level link the icon shows the Link block icon: I understand why this happens, and that this PR doesn't actually change this — the same thing happens in Maybe it should always show the root container (the Navigation block) as the parent? Or, maybe this would make more sense if there was an imaginary Sub-menu block? Either way, I think this PR should merge. 🚢 |
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.
Code looks good and it's working well ✅
Fwiw, I'm not bothered by the parent selector selecting the direct parent in a deeply nested situation, as both the visible outline around the currently selected block and the closing of submenu levels make it pretty clear what's going on.
Description
Fixes #28873
The
__experimentalCaptureToolbars
makes child block toolbars appear in the position of a parent block. However, the setting seems to work unreliably, sometimes the toolbar appears over a random block.The problem is that the feature uses a
__experimentalGetBlockListSettingsForBlocks
selector, and it seems the assumption is that this selector would return blocks in the same order as theclientIds
array passed in as the argument.That's not the case since the selector derives its return value from the
blockListSettings
state, which is an unordered associative array style object that maps clientIds to settings. The return value of the selector is also a compact array—where a block has no settings it isn't included in the results. Both of these qualities make it impossible to reliably reference theclientIds
passed in against the results of the selector.This PR changes
__experimentalGetBlockListSettingsForBlocks
so that instead of an array of block list settings, it returns an object where the keys are the requested client ids, and the values are the block setting objects. I think returning an object is the best option, since without theclientId
keys there are no clientId values in the results at all, making the API hard to use.How has this been tested?
Updated the unit tests for the selector.
Validate that #28873 is fixed
Screenshots
Before:
After
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: