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

Query Loop: Remove the Next Page link on empty query #36829

Closed
wants to merge 3 commits into from
Closed

Query Loop: Remove the Next Page link on empty query #36829

wants to merge 3 commits into from

Conversation

ivan-ottinger
Copy link
Contributor

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:

no-content

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), the Next 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.

Markup on 2021-11-24 at 15:01:18

How has this been tested?

  1. Create a new page and insert the Query Loop block into the content.
  2. Make sure there's also the Query Loop Pagination block present. This can be accomplished by clicking on "Start blank" and then selecting one of the options, e.g. "Title & Date" - as can be seen in the following screen recording:
Screen.Capture.on.2021-11-24.at.16-32-37.mp4
  1. 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:
    Markup on 2021-11-24 at 16:38:33

  2. 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 and npm test.

Screenshots

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • N/A I've included developer documentation if appropriate.
  • N/A I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

This commit adjusts the logic that handles the display of the `Next Page` link in the Query Loop Pagination block.

The change makes sure that when there are no query results, the `Next Page` link won't be displayed.

This addresses an issue reported at Automattic/wp-calypso#56504
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @ivan-ottinger! 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.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Nov 24, 2021
@carolinan carolinan added the [Block] Query Pagination Affects the Query Pagination Block - used for pagination within the Query Loop Block label Nov 25, 2021
@arunsathiya
Copy link
Contributor

arunsathiya commented Mar 25, 2022

When testing the below feature release, I noticed that the pagination does not appear anymore:

image

image

@ivan-ottinger
Copy link
Contributor Author

When testing the below feature release, I noticed that the pagination does not appear anymore:

Thanks Arun! I cannot reproduce the issue anymore either. → Closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Query Pagination Affects the Query Pagination Block - used for pagination within the Query Loop Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants