Skip to content
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

Fixed sorting bug for multi column sort #996

Merged
merged 1 commit into from
Feb 1, 2017
Merged

Fixed sorting bug for multi column sort #996

merged 1 commit into from
Feb 1, 2017

Conversation

victorkirov
Copy link
Contributor

There was a bug in multi column sort where the orders and sort fields would be reversed on table redraws without the user changing the sort info. This was because array.reverse() was used which changes the underlying array. Applying slice().reverse() first makes a copy of the original array and then returns the reverse of it, leaving the original arrays in a correct state.

There was a bug in multi column sort where the orders and sort fields  would be reversed on table redraws without the user changing the sort info. This was because array.reverse() was used which changes the underlying array. Applying slice().reverse() first makes a copy of the original array and then returns the reverse of it, leaving the original arrays in a correct state.
@AllenFang
Copy link
Owner

hello @varak69, thank your contribution, I'll review it as soon as possible, btw, is #973 (comment) the issue you try to solve?

@victorkirov
Copy link
Contributor Author

Hi @AllenFang

I took a look at that issue and commented as to why it isn't working. Just a spelling error.

This fix is for another issue which hasn't been logged but I came across it in our app. We had a table which was being unnecessarily redrawn on mouse enter/leave. Each time it was redrawn the order of the sort fields changed without them being changed by the user. I'll see if I can make a codepen for it.

@AllenFang
Copy link
Owner

thanks for quickly response :) it's awesome that you found the root cause for that issue, just a wrong spell.. 👍

@victorkirov
Copy link
Contributor Author

@AllenFang

Here's a codepen:
http://codepen.io/Varak/pen/egVzWz?editors=0010

As you can see, the sort order isn't changed anywhere in the codepen yet when the component rerenders (just move the mouse over it multiple times), the sort field and sort order array are reversed each time.

Copy link
Owner

@AllenFang AllenFang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fixed!

@AllenFang AllenFang merged commit b2ff491 into AllenFang:master Feb 1, 2017
@AllenFang
Copy link
Owner

Released on v2.11.0, thanks your contribution !!

@victorkirov
Copy link
Contributor Author

Thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants