Skip to content

Commit

Permalink
fix: tab controls not labeled properly
Browse files Browse the repository at this point in the history
The tab controls should be announced with the correct tab role, number and position as e.g., 'Smileys and People, selected, tab, 1 of 8'. Adding tablist role for the parent and tab role for the button does the trick.

I also modified aria-selected prop. Why? Using aria-selected={selected || undefined} can be problematic because it leads to inconsistent behaviour with how assistive technologies interpret the presence and value of the aria-selected attribute.

The aria-selected attribute is meant to have a clear true or false value to indicate the selected state.

Related to - PS-20553, PS-20638
  • Loading branch information
andrejkaPry committed May 17, 2024
1 parent 16978d0 commit 69cde30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/emoji-mart/src/components/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class Navigation extends PureComponent {
data-position={this.props.position}
dir={this.props.dir}
>
<div class="flex relative">
<div class="flex relative" role="tablist">
{this.categories.map((category, i) => {
const title = category.name || I18n.categories[category.id]
const selected =
Expand All @@ -73,10 +73,11 @@ export default class Navigation extends PureComponent {
return (
<button
aria-label={title}
aria-selected={selected || undefined}
aria-selected={selected ? 'true' : 'false'}
title={title}
type="button"
class="flex flex-grow flex-center"
role="tab"
onMouseDown={(e) => e.preventDefault()}
onClick={() => {
this.props.onClick({ category, i })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ button {
transition: transform var(--duration) var(--easing);
}

button[aria-selected] {
button[aria-selected="true"] {
color: rgb(var(--em-rgb-accent));
}
}
Expand Down

0 comments on commit 69cde30

Please sign in to comment.