Query Loop: Remove the Next Page
link on empty query
#36829
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
There's an issue (Automattic/wp-calypso#56504) that keeps the
Next Page
link in the Query Loop / Query Loop Pagination block visible in the front-end even in case when there is no content to be displayed:The proposed change adjusts the logic that handles the display of the
Next Page
link in a way that when there are no query results (0 === max_num_pages
/ no pages to display), theNext Page
link won't be displayed.When it comes to back-end, I think it would be worth leaving the default pagination displayed there even when there are no posts to be displayed at the time. This would make sure the user can still click on the pagination block and adjust its settings (e.g. label) for the time when the new posts meeting the filter criteria are published.
How has this been tested?
Screen.Capture.on.2021-11-24.at.16-32-37.mp4
Next, we need to make sure that no posts are displayed. One of the ways to make this happen is to create a new tag (Posts → Tags) that doesn't have any posts linked to it. Once the tag is created, we can select it in the Query Loop block settings:
Save the changes and take a look at the page in the front-end. There should be no
Next Page
link visible. In other words, it shouldn't be possible to reproduce the Query Loop: Pagination on Empty Query Automattic/wp-calypso#56504 issue.I have tested the change locally with
npm run lint
andnpm test
.Screenshots
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
*.native.js
files for terms that need renaming or removal).