components
components copied to clipboard
fix(paginator): update page index if invalid after length change
Updates the page index of a paginator if its length changed to something where the index isn't valid anymore (e.g. the user is on the last page and the amount of pages becomes smaller).
Fixes #14520.
I've been looking at @andrewseguin 's comments and I think that concern would be addressed by moving L136 to L130 (and L139 to L141, so that all the new code happens inside of the then
callback. The potential race condition arises because you're computing maxPageIndex
and looking at the current _pageIndex
value during the first tick but changing them during the second. If you do the comparison and change in a single tick, the race is eliminated.
@crisbeto it looks like your PR has fallen out of date please rebase the PR.
I've rebased the PR.