Skip to content

Since Gutenberg v19.3, allowedControls in core/query block variation are ignored in Site Editor's singular template editor and post editor #65902

@daviedR

Description

@daviedR

Description

Referring to the Extending the Query Loop Block documentation, we can use the allowedControls property in the core/query block variation definition to include only some of the controls in the editor.

For example, if a block variation defines: allowedControls: [], the block variation will not display any controls.

However, since Gutenberg v19.3, I have found that some controls are always displayed even if they are not defined in the allowedControls array when in the Site Editor's singular template editor and post editor. This issue doesn't occur in the Site Editor's index template editor.

Some of the affected controls are: postType, order, and sticky.

I tried to roll back to previous Gutenberg versions and discovered this issue doesn't happen in v19.2.

Changes in v19.3:
https://github.com/WordPress/gutenberg/blob/v19.3.0/packages/block-library/src/query/edit/inspector-controls/index.js#L125

Compared to v19.2:
https://github.com/WordPress/gutenberg/blob/v19.2.0/packages/block-library/src/query/edit/inspector-controls/index.js#L109

There's the additional logic of ! isTemplate that caused the issue.

Step-by-step reproduction instructions

Create a new block variation using this snippet:

registerBlockVariation(
	'core/query',
	{
		name: 'testing-allowed-controls',
		title: __( 'Testing Allowed Controls' ),
		category: 'theme',
		keywords: [],
		scope: [ 'inserter' ],
		attributes: {
			namespace: 'testing-allowed-controls',
		},
		allowedControls: [],
		innerBlocks: [],
		isActive: [ 'namespace' ],
	}
);

Go to 3 block editors:

  • Site Editor > Templates > Index
  • Site Editor > Templates > Single Posts
  • Posts > Add New, or edit an existing post (e.g. "Sample Page")

Add the Testing Allowed Controls query block variation into the block editor content via the inserter. Choose any inner blocks template.

Check the available controls in the block options panel (right sidebar).

Screenshots, screen recording, code snippet

Using the snippet above, these are 3 different screenshots:

Site Editor > Templates > Index Site Editor > Templates > Single Posts Post Editor (e.g. Sample Page)
Image Image Image

Environment info

WordPress 6.7 beta1

OR

WordPress 6.6.2
Gutenberg 19.3

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

Metadata

Metadata

Assignees

Labels

[Block] Query LoopAffects the Query Loop Block[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended[Type] RegressionRelated to a regression in the latest release

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions