WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.49k stars 4.18k forks source link

Setting 'parent' restriction in block API (block metadata) does not prevent the block from being transformed (wrapped) by group and column blocks. #66645

Open wwdes opened 1 day ago

wwdes commented 1 day ago

Description

The parent block API is not being honored by the transform options "Columns" and "Group" (and "Details" with Gutenberg plugin 19.5.0). According to block API reference: "Setting parent lets a block require that it is only available when nested within the specified blocks."

Step-by-step reproduction instructions

Set a custom block's parent metadata key to a specific parent block:

{ "parent": [ "core/cover" ] }

In the editor, create the cover block and insert your custom block. While selecting your custom block, click on the button that has the blocks icon in the floating toolbar to get the transform options. There are seen buttons: "Columns" and "Group" (and "Details" with Gutenberg plugin 19.5.0). When user clicks either of them, the custom block is now wrapped within the corresponding block, bypassing the restriction set by the parent block API.

Screenshots, screen recording, code snippet

No response

Environment info

Tested on WP 6.6.2 without Gutenberg plugin as well as with Gutenberg plugin 19.5.0.

Please confirm that you have searched existing issues in the repo.

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Please confirm which theme type you used for testing.