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

[Data Views] Adding aria-sort to table view headers #56860

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/dataviews/src/view-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ function ViewTable( {
// TODO:Add spinner or progress bar..
return <h3>{ __( 'Loading' ) }</h3>;
}

const sortValues = { asc: 'ascending', desc: 'descending' };
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't know if there's a general preference for raw objects or Maps, but happy to change this as necessary...

Suggested change
const sortValues = { asc: 'ascending', desc: 'descending' };
const sortValues = new Map([ ['asc', 'ascending'] , ['desc', 'descending'] ]);


return (
<div className="dataviews-table-view-wrapper">
{ hasRows && (
Expand All @@ -568,6 +571,11 @@ function ViewTable( {
.maxWidth || undefined,
} }
data-field-id={ header.id }
aria-sort={
sortValues[
header.column.getIsSorted()
]
}
>
<HeaderMenu
dataView={ dataView }
Expand Down
Loading