Query Loop block: perPage from custom block pattern is ignored when inserting block via block editor UI
Description
When inserting a Query Loop block on a page using the block editor, and selecting a block pattern, the perPage setting defined in the pattern is ignored, and instead is set to 10.
This only happens when inserting the block via the initial template selection screen. If I click "Change design" and select the same pattern again, the correct perPage is applied.
Step-by-step reproduction instructions
- Make sure you have more than 3 posts.
- Edit a page in the block editor.
- Insert a Query Loop block.
- Choose the pattern "List of posts, 1 column" in the initial selection popup. Expected: the query block shows 3 posts. Actual: the query block shows 10 posts.
Now click the block, click “Change design”, select the same custom pattern again.
Now the perPage setting is respected.
Screenshots, screen recording, code snippet
Environment info
WordPress: 6.8.1 Theme: twenty-twentyfive Browser: Chrome
Please confirm that you have searched existing issues in the repo.
- [x] Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- [x] Yes
Please confirm which theme type you used for testing.
- [x] Block
- [x] Classic
- [x] Hybrid (e.g. classic with theme.json)
- [ ] Not sure
While testing this further, I noticed that the perPage setting defined in the pattern is only respected if I switch the Query Loop block to use a custom query type and then change the design. Otherwise, when the block uses the default query (which is also the initial state when selecting a pattern), it continues to fallback to 10 no matter how many times I change the pattern.
So assume this issue is tied to the query type. When the block is using the default query type, the perPage from the pattern isn't applied. And when switching to custom query type, it correctly respects the pattern's perPage
This looks similar to #67288. cc @yogeshbhutkar
I'm pretty sure this is the same issue as #67288. Let's continue the discussion there.