DataViews: Enhance filterSortAndPaginate function by allowing args for pagination items
#70042
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.
Explore #70040
What?
Adds ability to pass totalItems & totalPages to filterSortAndPaginate to allow for hybrid approach for filtering and pagination.
Why?
When using the filterSortAndPaginate() function with paginated data from an API (where per_page=view.perPage), the function incorrectly calculates totalItems and totalPages based only on the records in the current page, not the total number of records in the database.
This causes pagination to break when using filterSortAndPaginate() with data from useEntityRecords() that's already paginated, as the function doesn't know about the total number of records available.
How?
This PR modifies the filterSortAndPaginate() function to accept an optional options parameter with totalItems and totalPages properties. When these values are provided, the function uses them instead of calculating pagination information from the data array.
This allows for a hybrid approach where:
Testing Instructions
Testing Instructions for Keyboard
No keyboard-specific testing is required as this change doesn't affect the user interface or keyboard navigation.
Screenshots or screencast
Not applicable as this is a functional change to an internal utility function with no direct UI impact.