Problem/Motivation

Not expected behavior from the pager.

Steps to reproduce

Given that the "Project Browser" module was installed under Drupal 9.2.x
And logged in as the "webmaster" user no. 1
When navigating to "/admin/modules/browse"
And check the "Accessibility" from "Categories"
Then the "28 projects" shows up under the pager with "3" pager links
When clicking on "3" pager link
Then the last "4" projects out of "28" will show up in the page
But the "Next" and "Last" will still show up in the pager too

When clicking "Next" or "Last"
Then the page will load "No records available"
And the "First", "Previous", "Next" , "Last" will still show up in the empty projects page.

Proposed resolution

More integrations for the pager web component to inline with Drupal core logic.

Remaining tasks

  • ✅ File an issue about this project
  • ☐ Addition/Change/Update/Fix to this project
  • ☐ Testing to ensure no regression
  • ☐ Automated unit/functional testing coverage
  • ☐ Developer Documentation support on feature change/addition
  • ☐ User Guide Documentation support on feature change/addition
  • ☐ Code review from 1 Drupal core team member
  • ☐ Full testing and approval
  • ☐ Credit contributors
  • ☐ Review with the product owner
  • ☐ Release

User interface changes

  • Have the right limit and links for the pager web component

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • N/A
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

RajabNatshah created an issue. See original summary.

rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

chrisfromredfin’s picture

Issue tags: +Project Browser MVP

tim.plunkett made their first commit to this issue’s fork.

tim.plunkett’s picture

Status: Active » Needs work
Issue tags: +Needs tests

# of projects changed since then, but the bug is still a problem.

This should be testable.

tim.plunkett’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

Tests added. Had to adjust the fixture a bit to get exactly 12 or 24 projects on a page at once, but chose the least invasive change (adding one category to one project).

fjgarlin’s picture

Assigned: Unassigned » fjgarlin
fjgarlin’s picture

Assigned: fjgarlin » Unassigned
Status: Needs review » Needs work

Clicking through pages returns now the expected results, with no overlapping and the expected results in the last page.

But I found a couple of pagination-related bugs:
* When you are in the last page, if you click "Next" or "Last", you get 0 results. ie: Filter by "Accessibility" and navigate to page 7, then click on either "next" or "last".
* When you are viewing results, if you click on "Last", you get 0 results. ie: Reload the page and click on "last".

tim.plunkett’s picture

Status: Needs work » Needs review

Good catch! Realized that sometimes it's 0-indexed and others it's 1-indexed. Standardized on 0-indexed to reduce total changes, and adjusted the tests

fjgarlin’s picture

Status: Needs review » Reviewed & tested by the community

Re-tested again and it all works as expected, including the cases mentioned above.
The tests come up green (including the newly added ones) and the code looks good.

Marking RTBC. Thanks!

bnjmnm’s picture

Status: Reviewed & tested by the community » Fixed

I see now how this was difficult to reproduce! The calculation determining the number of pages got messed up when the total was a multiple of the items-per-page because the total/perPage would be a whole number so Math.floor() wouldn't do the necessary -1. The solution elegantly addresses that, and the additional test coverage confirms it to be the case.

  • bnjmnm committed 6651ddc on 1.0.x authored by tim.plunkett
    Issue #3252678 by tim.plunkett, Rajab Natshah, fjgarlin: The pager is...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.