-
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: Add the Comments Pagination block #36872
Conversation
6df7b71
to
cebf7a4
Compare
Size Change: +413 B (0%) Total Size: 1.1 MB
ℹ️ View Unchanged
|
Thanks @c4rl0sbr4v0 for taking care of this. As I was the author of the original PR, I guess it wouldn't be OK to approve and merge my own PR 😅 , although from what @gziolo said in #36577 (comment) the PR should be ready to go. |
As long as you both agree this PR is good to go it’s just a formality who clicks the approve button 😃 I plan to have a closer look at this PR on Monday but you don’t need to wait for me. |
I created the PR, I cannot assign the review to me, neither merge 😆 I think the PR is good to go, after the merge, it will be updated once we merge and test the pagination links 😄 |
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.
Great work. Let’s land it and iterate in the other open PRs that introduce all necessary inner blocks. I left some feedback to consider as we continue development. I haven’t tested this PR as it’s going to be heavily tested with further work.
*/ | ||
return innerBlocks?.find( ( innerBlock ) => { | ||
return [ | ||
'core/query-pagination-next', |
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.
Names of those blocks need to be updated later.
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.
Sure! I guess the best way to address it is to do that in the PRs that implement the inner blocks.
* @return string Returns the wrapper for the Comments pagination. | ||
*/ | ||
function render_block_core_comments_pagination( $attributes, $content ) { | ||
if ( empty( trim( $content ) ) ) { |
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.
That’s a bit surprising but I checked the history of the Query Pagination block and it looks like they had an issue with rendering of an empty div
when there was no pagination to show. Basically it bails out early when inner blocks render nothing.
} | ||
} | ||
|
||
.block-library-comments-pagination-toolbar__popover .components-popover__content { |
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.
Where is it coming from? The class name isn’t prefixed with wp-
so it raises a flag, but it might be as well some legacy name we need to maintain.
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.
That CSS class is the same that the Query Pagination block has ― just changing query-pagination
by comments-pagination
(potential bad copy-paste? 👀 ).
By the way, I realized that the class name block-library-query-toolbar__popover
is being used inside the QueryToolbar
component (in the Query block), but the equivalent component for the Comments Query Loop block ― i.e. CommentsQueryLoopToolbar
― doesn't use any class.
I'm looking at whether it makes sense to add that style or not.
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.
OK, after taking a deeper look I don't see any reason to keep that style.
In fact, it seems we could also safely remove the same code from the Query Pagination block as well, right? There is no element using that class (if I'm not mistaken).
That class actually looks like a copy of this one from the Query block, which styles the QueryToolbar
component I mentioned previously.
Co-authored-by: Greg Ziółkowski <[email protected]>
39c618d
to
d5778b2
Compare
All tests were passing, so I have landed this PR. 🚀 |
Description
This block works as a container for other pagination blocks that render links to navigate through the list of comments. It basically works the same as the Query Pagination block, but for comments.
It has the same settings:
Will close #35007
Is a follow-up of #36577
How has this been tested?
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).