Repository navigation
fix(dropdown): only set aria-controls while the overlay is open - #1172
agundewar-eightfold wants to merge 2 commits into
Conversation
Closed dropdowns pointed aria-controls at an unmounted overlay id (WCAG 4.1.2).
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1172 +/- ##
==========================================
- Coverage 85.46% 85.46% -0.01%
==========================================
Files 1231 1231
Lines 21780 21786 +6
Branches 8295 8300 +5
==========================================
+ Hits 18614 18619 +5
- Misses 3078 3079 +1
Partials 88 88 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
src/components/Select/Select.tsx:1323 This |
@agupta-eightfold Good catch, fixed in c5eb59c. Keeping the menu mounted would mean a larger Dropdown change, and the menu also isn't rendered while loading or when no options match. So |
SUMMARY:
Dropdownsetaria-controlson its reference element on every render, but the overlay element that id points to is only mounted while the dropdown is open. While closed,aria-controlsreferenced an element that does not exist, which fails WCAG 4.1.2 (Name, Role, Value) in accessibility audits.aria-controlsis now only present while the overlay is rendered:aria-controlsisdropdownIdwhen open and omitted when closed.ariaRefreference element: the attribute is set when the overlay opens and removed when it closes. A value the consumer set on the element is left untouched, as before.This affects every component that renders a
Dropdowntrigger (for exampleMenubuttons,Navbar,Pagination,Tablefilters and dropdownTabs). Closed triggers no longer carryaria-controls; open triggers are unchanged.GITHUB ISSUE (Open Source Contributors)
N/A
JIRA TASK (Eightfold Employees Only):
https://eightfoldai.atlassian.net/browse/ENG-164559
CHANGE TYPE:
TEST COVERAGE:
TEST PLAN:
yarn storybook→ Dropdown story. With the dropdown closed, inspect the trigger button:aria-expanded="false"and noaria-controlsattribute.aria-expanded="true"andaria-controlsequal to theidof the rendered overlay.aria-controlsis removed again and focus returns to the trigger.ariaRef(e.g. a TextInput-based dropdown). The attribute is added and removed on theariaRefelement.