-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Paginator does not "reset" when new length is smaller than the previous shown length #5812
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
Comments
We intentionally did not design the paginator to adjust the page index automatically on length changes because there is not a consistent rule to follow here. For example, let's say that the length is 100 and the user is on the last page looking at items 90-100.
In each case, it is up to the developer to decide how to adjust the page index. In your case, when the user triggers a filter change, always set the paginator's page index to 0. This can be done by getting the paginator through For an example of this type of logic, check out this table's data source which listens for filter changes and resets the page index in response: https://plnkr.co/edit/LZ9HQnCKrmXm0g2vqVGH?p=preview |
Hello Andrew, That makes complete sense! I thought there would be some kind of method to provoke the 'reinitialization' of the paginator, however your approach makes more sense due to added flexibility. Thanks for the clarification! |
Thanks a lot andrewseguin. Your answer saved my time. |
The answer is great, I wish the documentation would say this upfront. Seems like this is common if you have a filter on the table. |
Thanks a lot for the solution! |
Why is |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Uh oh!
There was an error while loading. Please reload this page.
Bug, feature request, or proposal:
Reset paginator when the length property has changed, or provide a method we can call to do the reset manually.
What is the expected behavior?
Going back to pageIndex 0
What is the current behavior?
Page remains the same even if the length provided is smaller than pageIndex(+1) * pageSize
What are the steps to reproduce?
Go to a page in your data which has a range greater then the length of data after filtering.

E.g. (PageSize: 10) results 20-30 are shown, then when pressing some kind of filter you only have a length of results of 4 in total. It will show something like 20-24 (while it should be 1-4, and on pageIndex: 0)
What is the use-case or motivation for changing an existing behavior?
When having a use-case which is more 'complex' than paginating over a simple data set, the current paginator is not usable.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Latest version
The text was updated successfully, but these errors were encountered: