useSortBy sets descending on adjacent column not column that is clicked #4428
Unanswered
hughesthatgirl
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am using react-table v7 to create a basic datatable with column sorting. I am adding an
aria-sort
attribute to the column headers (<th>
) tags.What I am trying to do is make sure that when someone decides to sort a specific column, when
isSortedDesc
istrue
, thearia-sort
attribute should get set toaria-sort='descending'
otherwise it should be set toaria-sort='ascending'
and ifisSorted
is true then setaria-sort='none'
I am able to set
aria-sort
correctly based on the conditions, but the problem I'm running in to is that when I click on"First Name"
it doesn't change thearia-sort
attribute for that column but instead changes thearia-sort
attribute for"Last Name"
and so on.Any ideas why this is happening?
You can see the problem in this code sandbox. Inspect the table header and you should see the
aria-sort
attribute on each<th>
. Try to sort by"First Name"
and you will see that thearia-sort
attribute on"Last Name"
changes.https://codesandbox.io/s/happy-sammet-677rfi?file=/src/App.js
Beta Was this translation helpful? Give feedback.
All reactions