Uh oh!
There was an error while loading. Please reload this page.
fix(paginator): update page index if invalid after length change - #14625
fix(paginator): update page index if invalid after length change#14625crisbeto wants to merge 1 commit into
Conversation
| const currentPageIndex = this._pageIndex; | ||
| if (currentPageIndex > maxPageIndex && this.initialized) { | ||
| // Needs to happen on the next tick, in order to avoid "changed after checked" errors. |
There was a problem hiding this comment.
Why does this cause a changed after checked error?
There was a problem hiding this comment.
It's been a while so I don't remember the exact reason. I think it had to do with the page event being emitted at the wrong time the which would cause the table to be re-rendered after the changes were detected.
There was a problem hiding this comment.
I feel iffy about just throwing a microtask at it, especially without a clear explanation of why it's necessary.
534af71 to
9febcbeCompare9febcbe to
1b3c9f8Compare
andrewseguin
left a comment
There was a problem hiding this comment.
Little concerned about timing on this - could this interfere if the user tries to change the index and length at the same time? E.g. if the user changes the index + length, and the length gets set first, then a promise gets started that will change the index even though the user will have already changed it at that point
thw0rted
commented
Aug 6, 2021
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 |
nvaralakshmi
commented
Nov 23, 2021
@crisbeto it looks like your PR has fallen out of date please rebase the PR. |
…ange 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). Fixesangular#14520.
crisbeto
commented
Nov 23, 2021
I've rebased the PR. |
1b3c9f8 to
339c2ebCompare
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.