-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
__experimentalShareWithChildBlocks
should apply to all children, any depth in the inner-block hierarchy
#35078
Conversation
Size Change: +3 B (0%) Total Size: 1.06 MB
ℹ️ View Unchanged
|
It was intentional to start small since it’s an experimental API. The name used indicates that it applies only to child blocks - not all inner blocks. So it has to be a direct parent-child relationship. We can open it for deeply nested blocks but it needs to be opt-in because it will lead to unexpected issues. For instance, when you nest the same block type in itself, then you will have the same control type (example: align) from the grandparent and the parent block rendered in the toolbar next to each other. Duplicated controls that don't have a good visual reference to what they target might be very confusing for users. |
@gziolo Would this not also be the case in the direct child? Showing its own align control and the parent align control? Do you know of a block type that allows this to test this out? If the preference is a separate flag we can try updating this PR, but @senadir and I through a unified flag would be more intuitive when dealing with complex hierarchies. |
The issue of nested similar blocks is something we overlooked. I have no problem moving this to a separate flag and fixing it there. I think there's value in having it being nested deeply, and the issue of same blocks nested can be worked around somehow (limiting consumption to the nearest parent...) |
Buttons block and Social Icons block use that. It isn't an issue for a direct child, because all parent controls are grouped together in their toolbar group. So when both blocks have the same toolbar control, they are in different places.
It doesn't have to be a new flag. We can rename the existing one, and let it take different values so we could support both behaviors. For example, |
Description
When using controls using
__experimentalShareWithChildBlocks
, only the direct children show the controls.For example, if I have a block containing inner blocks, and have his defined:
I see the control when the top-level block is selected, and when its direct children (inner blocks) are selected:
Without this patch, any deeper inner blocks do not show the above control.
This code determines if parent controls are displayed. Notice is uses
hasSelectedInnerBlock
to determine if an inner block is selected and so needs the controls to be added. This does not factor in multiple levels of inner blocks hierarchy.hasSelectedInnerBlock
has support for adeep
parameter which searches inner blocks recursively. This is what we need here to solve the issue.How has this been tested?
This has been tested in WooCommerce Blocks only, with the above use case. I could find little usage of
__experimentalShareWithChildBlocks
in Gutenberg (ButtonEdit block uses it).ref: woocommerce/woocommerce-blocks#4812
Types of changes
This changes the behaviour of an experimental feature only available in this plugin.
Checklist:
*.native.js
files for terms that need renaming or removal).cc @senadir