-
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
[Block Library - Query Loop]: Try filters with ToolsPanel #42629
Conversation
Size Change: +527 B (0%) Total Size: 1.27 MB
ℹ️ View Unchanged
|
d9958c6
to
402bf1f
Compare
Nice! I think this is a step in the right direction, and will prove its value particularly when handling more complex post types with lots of custom taxonomies. On that note, for it to be really successful I wonder if the taxonomies should be split rather than grouped so that I can – for example – filter only by category. What do you think? |
Agreed, but I think we could explore this in a follow up. |
Nice! I think we could reduce the vertical spacing above |
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.
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.
Nice work @ntsekouras 👍
This works well for me, whether filtering posts or pages. Unit tests pass also.
I have one minor suggestion though. We don't need the panelId
props. That prop is only really required when the ToolsPanel
has its items rendered via a SlotFill and the one panel is "re-used" across blocks, for example, block supports.
I tested this using the diff below.
Example Diff
diff --git a/packages/block-library/src/query/edit/index.js b/packages/block-library/src/query/edit/index.js
index bc9175db6c..3cb7996aa2 100644
--- a/packages/block-library/src/query/edit/index.js
+++ b/packages/block-library/src/query/edit/index.js
@@ -104,7 +104,6 @@ export function QueryContent( {
return (
<>
<QueryInspectorControls
- clientId={ clientId }
attributes={ attributes }
setQuery={ updateQuery }
setDisplayLayout={ updateDisplayLayout }
diff --git a/packages/block-library/src/query/edit/inspector-controls/index.js b/packages/block-library/src/query/edit/inspector-controls/index.js
index b3268ba12f..2cea41ff5d 100644
--- a/packages/block-library/src/query/edit/inspector-controls/index.js
+++ b/packages/block-library/src/query/edit/inspector-controls/index.js
@@ -43,7 +43,6 @@ function useIsPostTypeHierarchical( postType ) {
}
export default function QueryInspectorControls( {
- clientId,
attributes: { query, displayLayout },
setQuery,
setDisplayLayout,
@@ -181,7 +180,6 @@ export default function QueryInspectorControls( {
} );
setQuerySearch( '' );
} }
- panelId={ clientId }
>
{ !! taxonomiesInfo?.length && (
<ToolsPanelItem
@@ -190,7 +188,6 @@ export default function QueryInspectorControls( {
onDeselect={ () =>
setQuery( { taxQuery: null } )
}
- panelId={ clientId }
isShownByDefault
>
<TaxonomyControls
@@ -203,7 +200,6 @@ export default function QueryInspectorControls( {
hasValue={ () => !! authorIds }
label={ __( 'Authors' ) }
onDeselect={ () => setQuery( { author: '' } ) }
- panelId={ clientId }
>
<AuthorControl
value={ authorIds }
@@ -214,7 +210,6 @@ export default function QueryInspectorControls( {
hasValue={ () => !! querySearch }
label={ __( 'Keyword' ) }
onDeselect={ () => setQuerySearch( '' ) }
- panelId={ clientId }
>
<TextControl
label={ __( 'Keyword' ) }
@@ -227,7 +222,6 @@ export default function QueryInspectorControls( {
hasValue={ () => !! parents?.length }
label={ __( 'Parents' ) }
onDeselect={ () => setQuery( { parents: [] } ) }
- panelId={ clientId }
>
<ParentControl
parents={ parents }
I like the idea of progressively unlocking complexity through explicitly adding one. |
fa8cffd
to
2c17c6b
Compare
I hid the |
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.
Commented on the wrong PR 🙈
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.
This is working well for me :)
filters.mp4
2ff41c0
to
185ab9d
Compare
🔥 |
The toolpanel doesn't include Parent as a filter option for Pages/hierarchical posts. Version 14.0 is fine 14.1 disappears |
Thanks for reporting this @antonyjsmith. This was fixed here: #44630 and was a regression from a different PR. |
What?
This PR uses
ToolsPanel
for displaying filters in Query Loop. It's an effort to make filters less overwhelming by adding only one default displayed filter for taxonomies(if any taxonomies exist).Screen.Recording.2022-08-01.at.2.34.05.PM.mov