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
Open
Fix pagination Next button visible when all data fits on one page#24206clcl777 wants to merge 2 commits intomatomo-org:5.x-devfrom
clcl777 wants to merge 2 commits intomatomo-org:5.x-devfrom
Conversation
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.
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'. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
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").
Root cause
When
filter_limitis-1(show all rows), the conditionoffsetEnd < totalRowswas evaluated as:offsetEnd = filter_offset + filter_limit = 0 + (-1) = -1-1 < totalRowsis alwaystruewhen there is any dataFix
Added a check for
filter_limit > 0to ensure the Next button is only shown when there'sactually a next page to navigate to.
Checklist
Review