Update to allow alternative Blocks to handle Grouping interactions#16278
Update to allow alternative Blocks to handle Grouping interactions#16278
Conversation
a492fb0 to
dc3bfb2
Compare
aduth
left a comment
There was a problem hiding this comment.
Should this other reference be updated as well?
gutenberg/packages/block-editor/src/components/block-actions/index.js
Lines 120 to 121 in f51f662
Less important, comment updates:
gutenberg/packages/blocks/src/api/factory.js
Line 150 in f51f662
gutenberg/packages/blocks/src/api/factory.js
Line 377 in f51f662
|
@aduth I've addressed those CR points. I have no clue why the PHP unit tests have suddenly started failing... |
3124452 to
46e6e15
Compare
Previously the method that determined whether a given Block was the block to be used for “Grouping” interactions was hardcoded as “core/group” within `isContainerBlock`. Updated to utilise the registered Grouping Block in order to allow alternative Blocks to be utilised for Grouping.
Currently this doesn’t work because window doesn’t have NODE defined.
…ouping Now using custom Gutenberg Plugin. Currently failing as the test Block appears to be unavailable within the Editor and doesn’t pass the `canInsertBlockType` test.
46e6e15 to
c7339a6
Compare
aduth
left a comment
There was a problem hiding this comment.
Another potentially useful consequence of these functions is to better accommodate scenarios where the grouping block isn't available (either because it's not been registered or in allowing to explicitly unset by setGroupingBlockName( null )).
… type registration" This reverts commit be6e767.
|
Thanks @aduth 👍 |
This PR will allow alternative Blocks to be used to handle Grouping interactions. Currently, you can only use
core/groupbut this PR will make it possible to register any valid Block as the Block to use when Grouping.Previously the method that determined whether a given Block was the block to be used for “Grouping” interactions was hardcoded as “core/group. This PR builds upon #15774 to allow alternative Blocks to be used to handle the Grouping interactions.
This should address some of the concerns raised in #14908 (comment), namely:
core/groupwithinpackages/blocks/src/api/factory.jsScreenshots
Below shows me registering the
test/alternative-group-blockBlock from a custom e2e testing Plugin as the default Grouping Block. I'm then using it within the Grouping interactions.How has this been tested?
How to test
wp-adminin the Gutenberg docker envGutenberg Test Custom Grouping BlockPlugin (important: be sure to deactivate this after you have finished testing!)window.wp.blocks.getGroupingBlockName()to get the current Grouping Block name - it should becore/group(the default).wp.blocks.setGroupingBlockName( 'test/alternative-group-block' );- it should register that block (provided by the Plugin activated above) as the default for GroupingQuestions
Is relying onNow usesgetGroupingBlockName()from the package here appropriate? I'm concerned I'm not using aselect()here.select().InnerBlocksare allowed. For example, you could try and registercoblocks/columnto act as the Grouping Block (it supportsInnerBlocksafter all) but within the correctconvert()(transform) definition it won't function as you'd expect.Types of changes
New feature (non-breaking change which adds functionality).
Checklist: