Skip to content

Keyboard accessibility improvements to Input component's dropdown area. #10554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

glastonbridge
Copy link
Contributor

Demo build: https://dropdown-key-input-capture.review-pxt.pages.dev/

This PR attempts to make keyboard accessibility closer to the WAI-ARIA standard for combo boxes when an input provides a dropdown. Specifically:

  • Down arrow opens the dropdown, where it exists
  • The dropdown is given focus and is navigable by arrow keys, space and enter to select, and escape to abort
  • There is only one active tab stop, removing the need for a separate stop to display the menu as that is nonstandard

How to test

  1. Enable the Accessible Blocks plugin and add a Sound Effect block (example project)
  2. Open the sound effect block using the keyboard and navigate to "Duration (ms)"
  3. Use down arrow to open the dropdown, space or enter to select, escape to leave the dropdown without selecting
  4. Observe it also works with mouse, or a combination of keyboard and mouse
  5. Observe that escape key and enter key have now got their usual functions in blockly (NB: escape will not close the Sound Effect editor while a HTML input, such as the collapsed "Duration (ms)" field, is selected. This is part of Blockly's implementation and is not solved here).
  6. Observe that the behaviour is correct on multiple openings of the dropdown and/or editor

Implementation concerns

Some of the accessible keys for a dropdown are intercepted by Blockly at a high level, specifically escape and enter, and these make accessible navigation problematic. I have implemented a lifecycle operation, to be enabled only for the lifetime of the visible dropdown, which blocks those keyboard shortcuts then reasserts them on close.

This is the best solution that I could find using the information I had, but it is unsatisfyingly complex and I welcome better ways to achieve this.

Whatever approach we use here will need to be extended to the Dropdown component too.

Copy link
Member

@riknoll riknoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently, react-common has no dependency on blockly and i'd like to keep it that way. react-common is shared between several of makecode's various webapps many of which have nothing to do with blockly at all.

is there a way we can make this a little more generic? could we create a wrapper component in webapp/ that handles the blockly side of things maybe?

@glastonbridge glastonbridge force-pushed the dropdown-key-input-capture branch from 910b96d to f993f1b Compare May 2, 2025 16:03
@glastonbridge
Copy link
Contributor Author

is there a way we can make this a little more generic? could we create a wrapper component in webapp/ that handles the blockly side of things maybe?

Hi @riknoll, thanks for your feedback, I appreciate the benefits of good separation of concerns. I've made an attempt to implement a wrapper component as you suggested, have a look at the latest commit and see what you think.

Copy link
Member

@riknoll riknoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! just remove the import

@riknoll
Copy link
Member

riknoll commented May 6, 2025

@glastonbridge looks like a linting issue! you can run gulp lint locally to check it

@riknoll riknoll merged commit 53f52ae into microsoft:master May 7, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants