-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[docs] Update the order of operations for pagination example so that slicing takes place after sorting. #34189
Conversation
Update the order of operations for pagination example so that slicing takes place after sorting. Signed-off-by: Marceli Wac <[email protected]>
|
Good catch! Could you please run |
@michaldudak Thanks, should be good now! |
One more thing to do. It seems your branch was based on master when we had problems with regression tests. Could you merge in the current master to fix the regression tests issue? It should be good to merge afterwards. |
@michaldudak Seems like this has gone through now :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right! Thanks for your work!
…g takes place after sorting. (mui#34189) Signed-off-by: Marceli Wac <[email protected]>
…g takes place after sorting. (mui#34189) Signed-off-by: Marceli Wac <[email protected]>
I believe this PR was an error and that the original comment was correct.
|
Hi @frontendlane,
But the slicing operation still needs to happen after sorting to account for all elements in the array. |
Thanks for replying @marceliwac. I still think the comment is incorrect. I believe there's a misunderstanding and I should have been clearer in my original comment. The comment mentions what to use in order to replace the call to
Modern browsers have changed their implementation of The To clarify, if you don't have to support IE your code lines 339 - 341 would look like this: {rows.slice().sort(getComparator(order, orderBy))
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
.map((row, index) => { I think the commend should be expanded to explain that modern browsers (i.e. non-IE) browsers render a call to |
@frontendlane You're also welcome to submit a PR with your comments. I will create it in the next few days otherwise. Thanks for bringing this up! |
Thanks @marceliwac , I'll create a PR tomorrow. |
This is a very minor tweak to the comment for non-IE11-supported pagination. The comment suggests using
.sort
instead ofstableSort
, but contrary to to example code which is valid, the comment's order of operations is wrong, resulting in a list of elements that are sorted, but only within the already-sliced array. Simply put, the suggestion in the comment introduces a bug.Signed-off-by: Marceli Wac [email protected]