-
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 posts list variation detection #58194
Conversation
Size Change: -84 B (0%) Total Size: 1.69 MB
ℹ️ View Unchanged
|
Flaky tests detected in 36307d8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7641722830
|
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.
🚢
@@ -53,6 +54,9 @@ const variations = [ | |||
}, | |||
}, | |||
scope: [ 'inserter' ], | |||
isActive: ( { namespace, query } ) => { | |||
return namespace === 'core/posts-list' && query.postType === 'post'; | |||
}, | |||
}, | |||
{ | |||
name: 'title-date', |
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.
The other variations like Title & Date or Title & Excerpt, would they benefit from isActive
, too?
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.
No, because they use the scope: [ 'block' ]
, which is used for the placeholder and they essentially are there to add some starting inner blocks.
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, thanks for a quick fix 👍
What?
Fixes: #58168
Core Query Loop's variation
posts list
was missing a proper way of being detected if is active(by not using theisActive
API). The reason for that is that the aforementioned API was introduced later.This PR uses the proper APIs for variations and additionally removes the
__experimentalGetMatchingVariation
(that you could say it evolved into thegetActiveBlockVariation
).Testing Instructions
Posts List
block(the variation) and observe that as long as you also preserve the queried postType to bepost
, the proper title is shown in all places(list view, block card, breadcrumbs, etc..)Bonus testing
blockTypes: ['core/query/posts-list'] and when you insert the block in the editor click
Choose`. Your pattern should be suggested.