Skip to content

Fix pagination Next button visible when all data fits on one page#24206

Open
clcl777 wants to merge 2 commits intomatomo-org:5.x-devfrom
clcl777:fix-pagination-button-visibility
Open

Fix pagination Next button visible when all data fits on one page#24206
clcl777 wants to merge 2 commits intomatomo-org:5.x-devfrom
clcl777:fix-pagination-button-visibility

Conversation

@clcl777
Copy link
Copy Markdown

@clcl777 clcl777 commented Mar 11, 2026

Description

Fixes an issue where the "Next" pagination button was incorrectly visible when all data fits on a single page in DataTable reports (e.g., Behaviour > Pages).

Problem

When the total number of rows is less than or equal to the page limit, the Next button should be hidden since there is no next page. However, the button remained visible and clickable.
Additionally, clicking the Next button in this state caused incorrect pagination values to be displayed (e.g., showing "0–124 of 124" or "-1–124 of 124").

image image image

Root cause

When filter_limit is -1 (show all rows), the condition offsetEnd < totalRows was evaluated as:

  • offsetEnd = filter_offset + filter_limit = 0 + (-1) = -1
  • -1 < totalRows is always true when there is any data

Fix

Added a check for filter_limit > 0 to ensure the Next button is only shown when there's
actually a next page to navigate to.

Checklist

  • [✔] I have understood, reviewed, and tested all AI outputs before use
  • [✔] All AI instructions respect security, IP, and privacy rules

Review

clcl777 added 2 commits March 3, 2026 12:27
When filter_limit is -1 (show all rows), the Next button was incorrectly
visible because offsetEnd (offset + limit) would be negative, which is
always less than totalRows.

Added check for filter_limit > 0 to ensure Next button is only shown
when there's actually a next page to navigate to.
@github-actions
Copy link
Copy Markdown
Contributor

If you don't want this PR to be closed automatically in 28 days then you need to assign the label 'Do not close'.

@github-actions github-actions bot added the Stale The label used by the Close Stale Issues action label Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stale The label used by the Close Stale Issues action

Development

Successfully merging this pull request may close these issues.

1 participant