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

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

Closed
2 tasks done
daviedR opened this issue Oct 7, 2024 · 6 comments · Fixed by #65984
Assignees
Labels
[Block] Query Loop Affects the Query Loop Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release

Comments

@daviedR
Copy link
Contributor

daviedR commented Oct 7, 2024

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
@daviedR daviedR added the [Type] Bug An existing feature does not function as intended label Oct 7, 2024
@ndiego
Copy link
Member

ndiego commented Oct 8, 2024

@daviedR does the previous functionality work in WordPress 6.6.2 without Gutenberg active?

@ndiego ndiego added the [Status] Needs More Info Follow-up required in order to be actionable. label Oct 8, 2024
@ndiego ndiego moved this to 🗣️ In Discussion / Needs Decision in WordPress 6.7 Editor Tasks Oct 8, 2024
@daviedR
Copy link
Contributor Author

daviedR commented Oct 9, 2024

@daviedR does the previous functionality work in WordPress 6.6.2 without Gutenberg active?

Yes, it works in WP 6.6.2 without Gutenberg plugin.

@t-hamano
Copy link
Contributor

t-hamano commented Oct 9, 2024

@mikachan @fabiankaegy

I think #65067 is related, but do you know if what's reported here is a bug or expected behavior? If it is expected, the documentation may need to be updated.

@fabiankaegy
Copy link
Member

fabiankaegy commented Oct 9, 2024

@t-hamano, from my perspective, this is definitely not intended behavior. #65067 intended to update the default way the control display. But it should 100% still respect the allowedControls option.

I do think this is a critical bug in 6.7 that needs to be resolved before the release.

@mikachan
Copy link
Member

mikachan commented Oct 9, 2024

Thanks for the ping, @t-hamano. I agree, this is not the intended behaviour. I'll look into this as soon as possible.

@ndiego ndiego moved this from 🗣️ In Discussion / Needs Decision to 📥 Todo in WordPress 6.7 Editor Tasks Oct 9, 2024
@ndiego
Copy link
Member

ndiego commented Oct 9, 2024

Yes, it works in WP 6.6.2 without Gutenberg plugin.

Thanks for the feedback everyone, I am going to list this as a regression.

@ndiego ndiego added [Type] Regression Related to a regression in the latest release [Block] Query Loop Affects the Query Loop Block and removed [Status] Needs More Info Follow-up required in order to be actionable. labels Oct 9, 2024
@mikachan mikachan self-assigned this Oct 9, 2024
@mikachan mikachan moved this from 📥 Todo to 🏗️ In Progress in WordPress 6.7 Editor Tasks Oct 9, 2024
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Oct 9, 2024
@mikachan mikachan moved this from 🏗️ In Progress to 🔎 Needs Review in WordPress 6.7 Editor Tasks Oct 9, 2024
@github-project-automation github-project-automation bot moved this from 🏗️ In Progress to ✅ Done in WordPress 6.7 Editor Tasks Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Query Loop Affects the Query Loop Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants