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

[Block Library]: Update the relationship of some posts needed inside Query Loop to ancestor #48348

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

ntsekouras
Copy link
Contributor

@ntsekouras ntsekouras commented Feb 23, 2023

What?

This PR just add a bit more flexibility to the insertion of Post Template, No results and Pagination inside a Query Loop block. Previously you could insert them through the inserter only if they were direct parents of Query Loop, but now they can be inserted in nested blocks(ex Group), as long as they have Query Loop as an ancestor.

Testing Instructions

  1. Inside a Query Loop block add a Group and then insert through the inserter Post Template, No results or Pagination blocks.
  2. The above three blocks cannot be inserted through the inserter if they don't have a Query Loop ancestor.
  3. No regressions are introduced and everything else should work as before.

@ntsekouras ntsekouras added [Package] Block library /packages/block-library [Block] Query Loop Affects the Query Loop Block [Block] Query Pagination Affects the Query Pagination Block - used for pagination within the Query Loop Block [Block] Post Template Affects the Post Template Block labels Feb 23, 2023
@ntsekouras ntsekouras self-assigned this Feb 23, 2023
@gziolo
Copy link
Member

gziolo commented Feb 23, 2023

Was there any discussion about which blocks could benefit from using ancestor instead of parent? Comments block could also get similar updates wherever applicable:

Screenshot 2023-02-23 at 12 23 48

Actually, it's the only block that uses that API, but in a slightly different way than this PR explores.

It also made me wonder whether the Comments block doesn't use ancestor for the Comment Template block to avoid the risk of inserting the block into self.

@ntsekouras
Copy link
Contributor Author

Was there any discussion about which blocks could benefit from using ancestor instead of parent?

In various issues at some point, but not a separate issue. We also introduced a new Query Loop PR that wraps these blocks inside Group blocks. That was my main trigger for this PR right now. I think the main reason for some comment blocks to use this API, is because they cannot work outside of this context at all.

It also made me wonder whether the Comments block doesn't use ancestor for the Comment Template block to avoid the risk of inserting the block into self.

That's a good point and is something we might not want for Post Template... Maybe @ockham or @c4rl0sbr4v0 could share some insights?

@webmandesign
Copy link
Contributor

+1 This would really be great! It would most likely solve my issue #48296 when I want to use core/query-pagination (and also core/comments-pagination) as a Template Part or Pattern.

@ntsekouras ntsekouras marked this pull request as draft June 30, 2023 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Template Affects the Post Template Block [Block] Query Loop Affects the Query Loop Block [Block] Query Pagination Affects the Query Pagination Block - used for pagination within the Query Loop Block [Package] Block library /packages/block-library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants