Skip to content
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

Innerblock not being restricted within groups #48311

Closed
ghost opened this issue Feb 22, 2023 · 9 comments
Closed

Innerblock not being restricted within groups #48311

ghost opened this issue Feb 22, 2023 · 9 comments
Labels
[Block] Group Affects the Group Block [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [Type] Enhancement A suggestion for improvement.

Comments

@ghost
Copy link

ghost commented Feb 22, 2023

Description

I am trying restrict the blocks that are available inside a group block, when I create a template for my innerBlocks.
I have tried the below, but this does not seem to work. Also the ALLOWED_BLOCKS does not work inside the group block either. All blocks are available to me for selection inside the group block.

	const ALLOWED_BLOCKS = ['core/group', 'core/image', 'core/paragraph', 'core/heading'];
	const MY_TEMPLATE = [
		['core/group', { lock: { 'move': true, 'remove': false }, allowedBlocks: ['core/heading'] }],
	];

	return (
		<div {...useBlockProps()}>
			<InnerBlocks
				allowedBlocks={ALLOWED_BLOCKS}
				template={MY_TEMPLATE}
			/>
		</div>
	);

Is this a bug?

I already created a ticket on the WordPress forum here: https://wordpress.org/support/topic/gutenberg-set-allowedblocks-for-the-core-group-block/, but did not get a reply, so hoping this will go quicker.

Step-by-step reproduction instructions

  1. Create a simple block with npx create-block
  2. Edit the block to use a template as above
  3. Add a block inside the group. You will see all blocks are available for selection.

Screenshots, screen recording, code snippet

No response

Environment info

Latest WordPress and Gutenberg at time of writing.

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

Yes

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

Yes

@kathrynwp kathrynwp added [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P Needs Testing Needs further testing to be confirmed. labels Feb 23, 2023
@github-actions
Copy link

Hi,
This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps.
Thanks for helping out.

@github-actions github-actions bot added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Mar 26, 2023
@ghost
Copy link
Author

ghost commented Mar 27, 2023

This is still a valid issue. Would be great if anyone would find the time to look at it.

@github-actions github-actions bot removed the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Mar 28, 2023
@landwire
Copy link

landwire commented Apr 3, 2023

Hi there, will anybody look at this in the near future?

@glendaviesnz glendaviesnz added [Block] Group Affects the Group Block [Type] Enhancement A suggestion for improvement. and removed Needs Testing Needs further testing to be confirmed. labels Apr 12, 2023
@glendaviesnz
Copy link
Contributor

I was able to replicate this issue. Currently, a group block specified in a template ignores the allowedBlocks setting.

@landwire
Copy link

landwire commented May 9, 2023

Hi @glendaviesnz
thank you for replicating the problem.
Do you know if anybody will look at this issue?

@glendaviesnz
Copy link
Contributor

glendaviesnz commented May 10, 2023

I am not sure where this sits in the priorities at the moment, or whether there is some intentional reason why the core Group block behaves like this, but I will try and take a closer look sometime next week to try and at least work out what might be required to fix it.

@landwire
Copy link

That's great. For me it is absolute essential that in certain scenarios the user does not have full access to all the blocks. It just makes it so much easier and manageable from a point of UI for the user to create content for certain blocks/areas, where the full selection of blocks is not needed.

@landwire
Copy link

As far as I know this has been resolved with a recent update of the Gutenberg plugin.

@t-hamano
Copy link
Contributor

I, too, have not been able to reproduce this issue with the latest Gutenberg, and it works as expected both with the useInnerBlocksProps hook and with the InnerBlocks component.

Perhaps this is due to the fact that the Group block did not originally have allowedBlocks attribute. The attribute was added in #49128 after this issue was submitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Group Affects the Group Block [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

4 participants