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

Nested SubRows Not Sorting #2303

Closed
Chase-Dickerson opened this issue May 12, 2020 · 7 comments · Fixed by #2443
Closed

Nested SubRows Not Sorting #2303

Chase-Dickerson opened this issue May 12, 2020 · 7 comments · Fixed by #2443
Labels

Comments

@Chase-Dickerson
Copy link

Chase-Dickerson commented May 12, 2020

Describe the bug
SubRows do not sort beyond a parent subRow of length 1.

Provide an example via Codesandbox!
https://codesandbox.io/s/nice-surf-hzprc

Steps To Reproduce (required)
Steps to reproduce the behavior:

  1. Go to the sandbox
  2. Click on any of the info columns to apply sorting
  3. Notice that no sorting occurs

Expected behavior
SubRows should sort at any depth.

Desktop / Smartphone:

  • OS: Any
  • Browser: Any
  • Version: Any

Additional context
The bug is caused by an early termination of subRow sorting, which occurs on this line:
https://github.com/tannerlinsley/react-table/blob/v7.0.5/src/plugin-hooks/useSortBy.js#L324
(EDIT: Updated link to point to version of react-table where issue was noticed)

Proposed Solution
Adjust the check for skipping subRow sorting so that it only skips subRows if the length of subRows is zero (i.e. change: !row.SubRows || row.subRows.length <= 1 to !row.SubRows || row.subRows.length === 0).

@dbertella
Copy link

oh wow thanks for this I was going to open the same issue today

@tannerlinsley
Copy link
Collaborator

🎉 This issue has been resolved in version 7.3.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Chase-Dickerson
Copy link
Author

Chase-Dickerson commented Sep 22, 2020

This issue is still not resolved on v7.3.4 or higher. See the provided sandbox, which references latest react-table (v7.5.1). @tannerlinsley

@aaryn101
Copy link
Contributor

@Chase-Dickerson I just tried it out on the sandbox, and it seems to be working. What am I missing?

Screen Shot 2020-09-22 at 2 02 54 PM

@Chase-Dickerson
Copy link
Author

Chase-Dickerson commented Sep 23, 2020

@aaryn101 Child rows do not sort when there is a single sub-row. Sorting is terminating too early because it sees a sub-row of length 1, which by itself constitutes as "sorted," ignoring other sub-rows further down the chain.
nested_sort

@aaryn101
Copy link
Contributor

@Chase-Dickerson Ahh, I see. I'll try to find some time this week to look into a fix.

@ghost
Copy link

ghost commented Sep 29, 2020

@aaryn101 Look at #2633
@tannerlinsley Can you merge this PR

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