fix(a11y): expose dropdown selection via aria-selected (D4) - #16
Conversation
Set aria-selected on every role=option so screen readers can determine the active choice; keep the checkmark as a redundant visual cue. Co-authored-by: Cursor <cursoragent@cursor.com>
📝 WalkthroughWalkthroughDropdown options now expose Possibly related issues
Possibly related PRs
Fixed issue severity 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/dropdown-focus.spec.js (1)
138-189: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd regression checks for the non-color selection cue.
The tests verify
aria-selectedand axe results, but they do not verify the.selectedclass or the decorative checkmark. Because the PR objective requires selection to remain visible without relying on color, add these assertions for the preselected and newly selected states. Also verify that deselected options have no checkmark.Suggested assertions
+ const selectedOption = basic.locator( + '[role="option"][aria-selected="true"]', + ); + await expect(selectedOption).toHaveClass(/selected/); + await expect( + selectedOption.locator( + '.dropdown-menu-item-checkmark[aria-hidden="true"]', + ), + ).toHaveCount(1); + await expect( + basic.locator( + '[role="option"][aria-selected="false"] .dropdown-menu-item-checkmark', + ), + ).toHaveCount(0);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/dropdown-focus.spec.js` around lines 138 - 189, Add regression assertions in the preselected and newly selected cases to verify the selected option has the `.selected` class and its decorative checkmark, while deselected options have neither the selected class nor a checkmark. Use the existing `selectionState`/dropdown locators around the tests for `#dropdown-preselected` and `#dropdown-basic`, preserving the current aria-selected and axe checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/dropdown-focus.spec.js`:
- Around line 138-189: Add regression assertions in the preselected and newly
selected cases to verify the selected option has the `.selected` class and its
decorative checkmark, while deselected options have neither the selected class
nor a checkmark. Use the existing `selectionState`/dropdown locators around the
tests for `#dropdown-preselected` and `#dropdown-basic`, preserving the current
aria-selected and axe checks.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: eba2c35c-ea9f-4783-8f5e-8c9df45750b4
📒 Files selected for processing (3)
components/dropdown/README.mdcomponents/dropdown/dropdown.jstests/dropdown-focus.spec.js
Summary
Closes #9 ([a11y][D4]). Dropdown options now expose selection programmatically with
aria-selected, so the active choice is not conveyed by color/checkmark alone.Changes
In
components/dropdown/:createMenuItem: everyrole="option"getsaria-selected="true"|"false"from the initialselectedValueselectItem: updatesaria-selectedalongside the.selectedclass and checkmarkaria-hidden); D2/D3 focus and combobox/listbox behavior unchangedTest plan
npm test— Playwright light + dark: preselected dropdown has exactly onearia-selected="true"; after select, selected option is"true"and others"false"; scoped axe cleanMade with Cursor