Skip to content
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

A11y Dropdown keyboard issue #1115

Closed
mlmoravek opened this issue Nov 15, 2024 · 0 comments · Fixed by #1143
Closed

A11y Dropdown keyboard issue #1115

mlmoravek opened this issue Nov 15, 2024 · 0 comments · Fixed by #1143
Labels
a11y Accessibility

Comments

@mlmoravek
Copy link
Member

The Dropdown component can't be controlled using the keyboard.

According to https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/ users should be able to use the arrow keys to highlight items and scroll through the list, and select items using Enter or the spacebar. I believe this would require tracking the currently highlighted item using state.

A quick and "dirty" but simple solution could be to register a @keypress handler on the dropdown item like this:

function onKeyPress(event: KeyboardEvent): void {
    if (!isClickable.value) return;
    if (event.key === "Enter" || event.key === " ") {
        event.preventDefault();
        parent.value.selectItem(itemValue as T);
        emits("click", itemValue as T, event);
    }
}

This would at least allow using the dropdown using keyboard only, since it is currently possible to tab through the items (not following spec either, but well).

Originally posted by @jh0ker in #596 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y Accessibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant