-
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
Query Pagination: do not render pagination container if there's no pagination #33635
Conversation
function render_block_core_query_pagination( $attributes, $content ) { | ||
$wrapper_attributes = get_block_wrapper_attributes(); | ||
|
||
if ( empty( $content ) || ctype_space( $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.
For some reason the $content
is a long string of whitespace when it's empty, so I added the ctype_space
condition.
Size Change: 0 B Total Size: 1.04 MB ℹ️ View Unchanged
|
e002f43
to
2f73b6b
Compare
The problem I am seeing with this is that when the block has already been saved it contains content like this:
Do we need to check for $content at all, or can we always just do a server rendering? |
I see what you mean. But if we don't check $content, how else could we avoid rendering an empty container? |
Hmm. I guess the alternative is to check for |
2f73b6b
to
6b32739
Compare
Thinking about this some more, I think it's good. If won't deal with blocks that have already been saved, but it will work for new blocks. |
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.
Closing in favor of #35092 |
Description
This PR adds a render callback to the query pagination block. This way, the pagination container element is only rendered if pagination exists.
I think rendering an empty container in most cases is harmless, but is it better to actually not add anything to the DOM if there isn't content present? There are probably other cases where this happens in FSE blocks..
This is an attempt to solve Automattic/themes#4268 where we style the wrapper only when pagination is present.
How has this been tested?
Screenshots
Types of changes
Bug fix?
Checklist:
*.native.js
files for terms that need renaming or removal).