-
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
Site Editor: Add new Comments Query Loop block #35231
Site Editor: Add new Comments Query Loop block #35231
Conversation
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @michalczaplinski! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
1f39143
to
16ee987
Compare
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.
Query Loop is quite a big block with several functionalities added over time. It took months to develop it. I guess the best approach would be to start simple and code only a small subset of features. @ntsekouras might have the best recommendation here. Definitely, a good start would be to have a Comments Query Loop and Comment template block with some enforced layout for start with simple controls that change some common query attributes.
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.
Thanks for the comments @gziolo! I've reduced the scope of this PR to remove the variations, and CommentsQuerySetup
and kept just the 3 attributes: perPage
, pages
and offset
for now.
I would appreciate some more eyes on this PR - perhaps @ntsekouras also could take a look to let me know what else you would like to see here in order for this PR to land?
No idea why e2e tests are failing but it seems unrelated...? 🤔 |
I think this block should have e2e tests similar to ones for the |
Thanks for working on this @michalczaplinski - this is awesome! I'll take a closer look later to review properly but for now I was just wondering if it makes sense to revisit the design/position of the controls. On one hand it would be good to be consistent between similar blocks, on the other hand if the attributes are fewer, we could move them to the --cc @jameskoster @jasmussen |
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.
Thanks for working on this Michal!
This is probably a chance for us to enforce all the new stuff (like layout
) and handle better some challenges that we faced with Query Loop
. In general I think more things to discuss will be exposed when you start the implementation of Comments Loop
client and server side.
I would be in favour of maintaining consistency across the query blocks for now, then addressing the issues of the current UX subsequently and applying any fixes to all blocks at the same time. |
1bca6cc
to
8fe3842
Compare
We need to sort out the execution plan before we land this PR. At the moment there are two existing blocks:
They are going to be replaced with:
Now the question is how we approach that:
Do we have other options available that I missed? Is it something that you already know how to address? /cc @mtias and @youknowriad. |
Potentially, we could keep the old block only in the plugin and only backport one of them to Core. For Post, we did keep both blocks (latest posts and Query Loop). |
I forgot about Latest Comments. It is there as well:
At the moment, we have the experimental Post Comments block that is very simple and seems to be a blocky version of
There is also an existing experimental Post Comment block that requires providing the comment id by the user in the editor: gutenberg/packages/block-library/src/post-comment/edit.js Lines 42 to 47 in 39be23f
This PR proposes a Comments Query Loop block that is a more advanced version of Post Comments. The other block Comments Template is very similar to the existing Post Comment block. |
df17429
to
0a97105
Compare
I'd like to understand what else would be needed in order to land this PR? I only have this on my todo list but there's probably more that I'm missing:
@gziolo @ntsekouras would you like to give it another look? |
f6c69a4
to
0264d67
Compare
Yeah, I was also thinking of |
My current concern is how to handle the nested comments. It seems to me that that the best way would be to convert the list of comments passed in gutenberg/packages/block-library/src/comment-template/edit.js Lines 47 to 52 in 1668cd3
to a format that includes an array of [
{ commentId: 1, children: [] },
{
commentId: 2, children: [
{ commentId: 3, children: [] },
{ commentId: 4, children: [
{ commentId: 5, children: [] }
] },
],
},
{ commentId: 3, children: [] },
]; You get the idea. Probably would need to split the ` into 2 components. The first one that contains the logic and the second one that "just" renders the content given some props. Then, that second component call itself recursively (if the comment has children) so that I can represent each level of comment nesting. |
I think the first iteration could skip this and after landing, create a quick follow up for the nested handling. What do you think? |
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.
Awesome work. I think it's in good shape already so we can land it to start testing in the Gutenberg plugin. We still have almost a week before the 11.9 RC1 happens to implement more features necessary for the Comments Query Loop block. The biggest benefit of landing this PR early is that we can start deprecating the Post Comment block in favor of the Comment Template block.
Great work! 🚀 |
Description
Fixes #34996
Fixes #35000
block-library
.core/comment-template
block which is kept to the bare minimum to make the comments query work.How has this been tested?
Tested manually:
/comment
Comment Query Loop
blockperPage
,pages
oroffset
attributes in the toolbar and observe them change in the UIEnvironment details
wp-env
defaultwp-env
default14.17.6
6.14.15
Screenshots
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).