-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(sort): add aria-sort to host when sorted #6891
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
Conversation
src/lib/sort/sort-header.ts
Outdated
@@ -46,6 +46,7 @@ import {getMdSortHeaderNotContainedWithinMdSortError} from './sort-errors'; | |||
styleUrls: ['sort-header.css'], | |||
host: { | |||
'(click)': '_sort.sort(this)', | |||
'[attr.aria-sort]': '_getAriaSortAttribute()', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the reader announce when we have both the aria-sort
and the description?
Could you try this in NVDA and VoiceOver as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's JAWS with different options (with/without aria-sort/visually-hidden div)
With aria-sort, without visually-hidden: change sorting for userid button sorted ascending
Without aria-sort, with visually-hidden: change sorting for userid button sorted by userid ascending
With both: change sorting for userid button sorted ascending sorted by userid ascending sorted ascending
Checking out NVDA and VoiceOver...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NVDA was similar, wasn't able to get VoiceOver to play nice.
* ensures this is true. | ||
*/ | ||
_getAriaSortAttribute() { | ||
if (!this._isSorted()) { return null; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be none
when it's not sorted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the spec, For each table or grid, authors SHOULD apply aria-sort to only one header at a time.
so by returning null, the attribute is removed altogether rather than being set to 'none'
since it's possible another header now has aria-sort
applied
src/lib/sort/sort-header.ts
Outdated
@@ -113,4 +114,16 @@ export class MdSortHeader implements MdSortable { | |||
_isSorted() { | |||
return this._sort.active == this.id && this._sort.direction; | |||
} | |||
|
|||
/** | |||
* Returns the aria-sort attribute that should be applied to this sort header. If this header |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer Gets
to Returns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/lib/sort/sort-header.ts
Outdated
@@ -83,15 +84,16 @@ export class MdSortHeader implements MdSortable { | |||
get _id() { return this.id; } | |||
set _id(v: string) { this.id = v; } | |||
|
|||
constructor(public _intl: MdSortHeaderIntl, | |||
constructor(public intl: MdSortHeaderIntl, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean for this to be part of the public api now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to find the discussion about it, but can't find it. It seems people already are using it and would like to have it part of the public API. Wrong PR to put this in, but curious what you think about allow people to access it directly
Looks like some lint errors |
a0daa02
to
1923192
Compare
Fixed lint issues |
1923192
to
f9d1d46
Compare
f9d1d46
to
2727cd6
Compare
2727cd6
to
d992b82
Compare
Marking as a major release due to the removal of some HTML elements |
@andrewseguin please rebase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks, rebased |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Apply the
aria-sort
label to the sort header rather than include an additional visually hidden div to describe the sort.Screenreaders will read this and append the phrase "Sorted ascending" or "Sorted descending" after reading the header content. Similar to what we had previously.
Up for debate: this property should only be applied to elements with role
columnheader
orrowheader
. Should we only apply this property in those cases? If so, do we add in thesortDescriptionLabel
to be displayed in the cases where the roles are not defined?https://www.w3.org/TR/wai-aria/states_and_properties#aria-sort
Closes #6874