-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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]: Suggest active variation patterns #44197
Conversation
Size Change: +1.25 kB (0%) Total Size: 1.26 MB
ℹ️ View Unchanged
|
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.
I haven't tested much, but the implementation looks good.
Tested the setup and replace flows and works as advertised (loads the specific pattern if the theme has declared any and fallbacks to the query ones if the theme didn't declare one). |
This is great!
Should we be merging the patterns from the variation and the Query defaults instead of replacing? Though I guess it's better like this given a general purpose query pattern can be extended to cover your block type by registering your block type explicitly in its |
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.
I tested it and LGTM! Thanks for your effort!
* [Block Library - Query Loop]: Suggest active variation patterns * optimization when no active variation exists * minor tweak * comment clarification
I just cherry-picked this PR to the wp/6.1 branch to get it included in the next release: 8edb659 |
What?
With this PR it's possible to create Query Loop patterns for a specific block variation in the set up and replace flows.
The block determines if there is an active variation of the block and if there are available specific patterns for this variation. If there are, these patterns are going to be the only ones suggested to the user in setup and replace flow, without including the default ones for Query Loop. If there are no such patterns, the default ones for Query Loop are going to be suggested.
In order for a pattern to be 'connected' with a Query Loop variation, you should add to the pattern's
blockTypes
property the name of your variation prefixed with the Query Loop name(excore/query/$variation_name
). This is the same convention we are also following for Template Parts, which also have similar flows for setup/replace.Testing Instructions
Products List
blockProducts List
block the suggested patterns should be the default for Query LoopScreenshots or screencast
Screen.Recording.2022-09-15.at.5.31.23.PM.mov