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

Table: Sorting not working as expected #4086

Closed
Mental1993 opened this issue Oct 10, 2020 · 5 comments · Fixed by #4097
Closed

Table: Sorting not working as expected #4086

Mental1993 opened this issue Oct 10, 2020 · 5 comments · Fixed by #4097

Comments

@Mental1993
Copy link
Contributor

Mental1993 commented Oct 10, 2020

Bug Report

Sorting in table does not work as expected

Steps

I copy and pasted the code from https://react.semantic-ui.com/collections/table/#variations-sortable. Sorting works fine the first time you sort for example name column or when you change column. But the second time you try to sort, it doesn't work

Expected Result

Sorting should be working, like the example in the docs

Actual Result

Sorting stops working after the first time.

Version

2.0.0

Proposal for fix

Maybe the reducer doesn't like the fact that it's state is manipulated directly (state.data.reverse()), so i tried to solve it by

  1. using the lodash method for sorting and clone data: _.reverse(_.clone(state.data))
  2. without the use of lodash data: state.data.slice().reverse()
    Both ways seemed to work.
@welcome
Copy link

welcome bot commented Oct 10, 2020

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you've completed all the fields in the issue template so we can best help.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@aluck101
Copy link

Bug Report

Sorting in table does not work as expected

Steps

I copy and pasted the code from https://react.semantic-ui.com/collections/table/#variations-sortable. Sorting works fine the first time you sort for example name column or when you change column. But the second time you try to sort, it doesn't work

Expected Result

Sorting should be working, like the example in the docs

Actual Result

Sorting stops working after the first time.

Version

2.0.0

Proposal for fix

Maybe the reducer doesn't like the fact that it's state is manipulated directly (state.data.reverse()), so i tried to solve it by

  1. using the lodash method for sorting and clone data: _.reverse(_.clone(state.data))
  2. without the use of lodash data: state.data.slice().reverse()
    Both ways seemed to work.

I have the same problem, and this seems to work for me.

@layershifter
Copy link
Member

@Mental1993 I don't see the issue in our docs but you're correct: .reverse() mutates an array. I like the approach with .slice(), would you like to submit a PR?

@saideepesh000
Copy link

@layershifter, Hey can I work on this.

@Mental1993
Copy link
Contributor Author

@layershifter Will do;)

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

Successfully merging a pull request may close this issue.

4 participants