-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
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
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.
Should this other reference be updated as well?
gutenberg/packages/block-editor/src/components/block-actions/index.js
Lines 120 to 121 in f51f662
// Activate the `transform` on `core/group` which does the conversion | |
const newBlocks = switchToBlockType( blocks, 'core/group' ); |
Less important, comment updates:
gutenberg/packages/blocks/src/api/factory.js
Line 150 in f51f662
// Don't allow single 'core/group' blocks to be transformed into |
gutenberg/packages/blocks/src/api/factory.js
Line 377 in f51f662
// Unless it's a `core/group` Block then for multi block selections |
gutenberg/packages/editor/src/components/convert-to-group-buttons/convert-button.js
Line 102 in f51f662
// Activate the `transform` on `core/group` which does the conversion |
@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
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.
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/group
but 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/group
withinpackages/blocks/src/api/factory.js
Screenshots
Below shows me registering the
test/alternative-group-block
Block 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-admin
in the Gutenberg docker envGutenberg Test Custom Grouping Block
Plugin (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()
.InnerBlocks
are allowed. For example, you could try and registercoblocks/column
to act as the Grouping Block (it supportsInnerBlocks
after 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: