-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Query Loop: Fix isControlAllowed and isTemplate combined logic #65984
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -11 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
@@ -123,21 +123,18 @@ export default function QueryInspectorControls( props ) { | |||
const showInheritControl = | |||
isTemplate && isControlAllowed( allowedControls, 'inherit' ); | |||
const showPostTypeControl = | |||
( ! inherit && isControlAllowed( allowedControls, 'postType' ) ) || | |||
! isTemplate; | |||
! inherit && isControlAllowed( allowedControls, 'postType' ); |
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.
inherit
is already being set to false if on singular content in query-conent.js, so we can remove the isTemplate
check from these lines.
The only isTemplate
check we need here is the one on line 124, as this decides whether to show the inherit control or not, and the intended behaviour is for this control to only show when on non-singular content (and if the control is allowed).
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.
Thanks for the PR!
I tried enabling only some controls as shown below, and it seems to work properly:
wp.blocks.registerBlockVariation(
'core/query',
{
name: 'testing-allowed-controls',
title: 'Testing Allowed Controls',
category: 'theme',
keywords: [],
scope: [ 'inserter' ],
attributes: {
namespace: 'testing-allowed-controls',
},
allowedControls: ['author', 'search'],
innerBlocks: [],
isActive: [ 'namespace' ],
}
);
However, I'm not familiar with the recent changes to the Query Loop block. I'd be grateful if @fabiankaegy could help me 🙏
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.
In my quick testing this fixes the issue :) Thank you for the quick fix ❤️
* Fix isControlAllowed and isTemplate logic * Remove isTemplate check when inherit is already being checked Co-authored-by: mikachan <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: fabiankaegy <[email protected]> Co-authored-by: ndiego <[email protected]> Co-authored-by: daviedR <[email protected]>
I just cherry-picked this PR to the wp/6.7 branch to get it included in the next release: 541fe25 |
* Fix isControlAllowed and isTemplate logic * Remove isTemplate check when inherit is already being checked Co-authored-by: mikachan <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: fabiankaegy <[email protected]> Co-authored-by: ndiego <[email protected]> Co-authored-by: daviedR <[email protected]>
…ress#65984) * Fix isControlAllowed and isTemplate logic * Remove isTemplate check when inherit is already being checked Co-authored-by: mikachan <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: fabiankaegy <[email protected]> Co-authored-by: ndiego <[email protected]> Co-authored-by: daviedR <[email protected]>
What?
This fixes the logic for showing the
allowedControls
for the Query Loop block in combination with the newisTemplate
check from #65067.Why?
Fixes #65902.
How?
Previously, the
isTemplate
check was considered separately from theisControlAllowed
check, and now with this PR, the logic is combined. This wasn't an intentional change to the logic, so this is a pure bug fix.Testing Instructions
These are taken from the testing instructions in #65902:
Create a new block variation using this snippet:
Go to 3 block editors:
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), and ensure that no controls are available on single posts or pages.
Screenshots or screencast