Skip to content

Commit

Permalink
fix(LocaleSelector): Set aria-controls only when selector is open.
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-dam-ibigroup committed Apr 19, 2023
1 parent 603f12e commit d90893a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/components/util/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ const Dropdown = ({
style={{ float: pullRight ? 'right' : 'left' }}
>
<DropdownButton
aria-controls={id}
// Only set aria-controls when the dropdown is open
// (otherwise, assistive technologies may not announce the dropdown correctly).
aria-controls={open ? id : undefined}
aria-expanded={open}
aria-haspopup="listbox"
aria-label={label}
Expand All @@ -175,7 +177,7 @@ const Dropdown = ({
{open && (
<DropdownMenu
aria-label={listLabel}
aria-labelledby={listLabel ? '' : `${id}-label`}
aria-labelledby={listLabel ? undefined : `${id}-label`}
id={id}
onClick={toggleOpen}
role="list"
Expand Down

0 comments on commit d90893a

Please sign in to comment.