Skip to content
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

Allow Query block variations to specify query attributes without defining innerBlocks #50457

Open
jeremyfelt opened this issue May 9, 2023 · 0 comments
Labels
[Block] Query Loop Affects the Query Loop Block [Type] Enhancement A suggestion for improvement.

Comments

@jeremyfelt
Copy link
Member

Description

I've registered a variation for a custom post type that sets an initial perPage value of 99 along with some other attributes.

When I first add the variation to the editor, I see:

<!-- wp:query {"query":{"postType":"person","perPage":99,"inherit":false},"namespace":"project/people"} -->
<div class="wp-block-query"></div>
<!-- /wp:query -->

I'm then presented an option to choose a pattern, which I expect. I select "Start blank" to choose one of the basic layouts provided for the query block. I then select "Title & Date" to populate a basic layout for the query.

This becomes:

<!-- wp:query {"queryId":1,"query":{"perPage":3,"pages":0,"offset":0,"postType":"person","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false},"namespace":"project/people"} -->

The originally selected variation's attributes have been overwritten by default attributes assigned to all core query variations.

My expectation is that the editor should respect the defaults I've applied to the initial variation.

Ideally, variations like "Title & Date" should only make changes to the layout of the Post Template block and not set any attributes in the query block. Less ideally, but also perfectly fine: it should merge itself with the first selected variation so that expectations can be set. Maybe an additional property of variations could be how they handle chaining?

In the current form, it seems that innerBlocks must be defined in the variation in order to have the variation attributes survive the initial insertion. The documentation kind of alludes to this, but it's not entirely clear.

Step-by-step reproduction instructions

  1. Register a block variation for core/query with perPage set to 99.
  2. Insert the block variation.
  3. Select "Title & Date".
  4. Expect perPage to be set to 99. See that it's set to 3.

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress 6.2 with and without Gutenberg 15.7.0 active.

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

No

@jeremyfelt jeremyfelt added the [Block] Query Loop Affects the Query Loop Block label May 9, 2023
@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Query Loop Affects the Query Loop Block [Type] Enhancement A suggestion for improvement.
2 participants