This project is meant to teach software engineers how to create accessible listbox components in React.
You can view the demo app here: http://tylerhawkins.info/a11y-listbox/build/
This project was bootstrapped with Create React App.
In the project directory, you can run:
build: Builds the appeject: Ejects the app from using react-scriptsformat: Formats the code using Prettierformat-watch: Formats the code using Prettier in watch modestart: Starts the app in development modetest: Runs the teststest-watch: Runs the tests in watch mode
- Clicking the trigger button should show/hide the listbox options
- Items should be hoverable and selectable with the mouse
- When an item is clicked, the listbox should be closed and focus should be returned to the trigger button
- Clicking away from the open listbox should close the listbox and return the focus to the trigger button
- Pressing the
Enter/Spacekey on the trigger button should show/hide the listbox options - Pressing the
Down ArroworUp Arrowon the trigger button when the listbox is closed should open the listbox - Items should be focusable and selectable with the keyboard
Down Arrow: moves focus down by one itemUp Arrow: moves focus up by one itemEnter: selects the currently focused item and closes the listbox and returns the focus to the trigger buttonEscape: closes the listbox without making a selection and returns the focus to the trigger buttonHome: moves focus to the first itemEnd: moves focus to the last item
- When focus is moved to an item out of view, listbox should be scrolled so that the item is visible
- Trigger button should have
aria-haspopup="listbox",aria-labelledby, andaria-expandedattributes <ul>element should haverole="listbox",aria-labelledby, andaria-activedescendantattributes<li>elements should haverole="option"andaria-selectedattributes