Skip to content

Commit

Permalink
Make Query Loop settings more intuitive with a ToggleGroup and simpli…
Browse files Browse the repository at this point in the history
…fied help text (#63739)

* Replace Toggle with ToggleGroup for inherit control in Query Loop

* Update a test based on Inherit query from template control

* Simplify ternary operator

* Update controls description in Queryn Loop block

* remove const for labels used once

* Add __next40pxDefaultSize

---------

Co-authored-by: kmanijak <[email protected]>
Co-authored-by: richtabor <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: jameskoster <[email protected]>
  • Loading branch information
5 people authored Jul 26, 2024
1 parent 3c53a6a commit 062efa7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
41 changes: 28 additions & 13 deletions packages/block-library/src/query/edit/inspector-controls/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
TextControl,
SelectControl,
RangeControl,
ToggleControl,
__experimentalToggleGroupControl as ToggleGroupControl,
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
Notice,
Expand Down Expand Up @@ -103,9 +102,9 @@ export default function QueryInspectorControls( props ) {
const showInheritControl = isControlAllowed( allowedControls, 'inherit' );
const showPostTypeControl =
! inherit && isControlAllowed( allowedControls, 'postType' );
const postTypeControlLabel = __( 'Content type' );
const postTypeControlLabel = __( 'Post type' );
const postTypeControlHelp = __(
'WordPress contains different types of content you can filter by. Posts and pages are the default types, but plugins could add more.'
'Select the type of content to display: posts, pages, or custom post types.'
);
const showColumnsControl = false;
const showOrderControl =
Expand Down Expand Up @@ -146,17 +145,33 @@ export default function QueryInspectorControls( props ) {
{ showSettingsPanel && (
<PanelBody title={ __( 'Settings' ) }>
{ showInheritControl && (
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Inherit query from template' ) }
help={ __(
'Enable to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'
) }
checked={ !! inherit }
onChange={ ( value ) =>
setQuery( { inherit: !! value } )
<ToggleGroupControl
__next40pxDefaultSize
label={ __( 'Query type' ) }
isBlock
onChange={ ( value ) => {
setQuery( { inherit: !! value } );
} }
help={
inherit
? __(
'Display a list of posts or custom post types based on the current template.'
)
: __(
'Display a list of posts or custom post types based on specific criteria.'
)
}
/>
value={ !! inherit }
>
<ToggleGroupControlOption
value
label={ __( 'Default' ) }
/>
<ToggleGroupControlOption
value={ false }
label={ __( 'Custom' ) }
/>
</ToggleGroupControl>
) }
{ showPostTypeControl &&
( postTypesSelectOptions.length > 2 ? (
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/editor/various/is-typing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ test.describe( 'isTyping', () => {
.click();

await editor.openDocumentSettingsSidebar();
await page.getByLabel( 'Inherit query from template' ).click();
await page.getByLabel( 'Custom' ).click();

// Moving the mouse shows the toolbar.
await editor.showBlockToolbar();
Expand Down

0 comments on commit 062efa7

Please sign in to comment.