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

Consider adding aria-activedescendant to support VoiceOver #92

Closed
airjp73 opened this issue Feb 24, 2023 · 1 comment · Fixed by #108
Closed

Consider adding aria-activedescendant to support VoiceOver #92

airjp73 opened this issue Feb 24, 2023 · 1 comment · Fixed by #108

Comments

@airjp73
Copy link

airjp73 commented Feb 24, 2023

By default, cmdk doesn't seem to be accessible to VoiceOver (Mac). I'm guessing this is just an edge-case / difference between different screen readers. I figured out how to fix the issue in my project, but I think it would make sense for this to be built into the library itself.

To get it to work well with VoiceOver, I had to add aria-activedescendant to the command input. I've added screen recordings for a "before" and "after" to the bottom of this issue.

// CommandItem component
const id = useId();
return <Command.Item id={id} {...etc} />

// CommandInput component
const value = useCommandState((state) => state.value);
const [id, setId] = React.useState<string | undefined>(undefined);

useEffect(() => {
  const nextId = document.querySelector(`[cmdk-item=""][data-value="${value}"]`)?.id;
  setId(nextId);
}, [value]);

return <Command.Input aria-activedescendant={id} {...etc} />

Thanks for the great library!


Before the change

before.mp4

After the change

after.mp4
@joaom00
Copy link
Contributor

joaom00 commented Mar 9, 2023

Cmdk also does not seem to be accessible to NVDA (Windows). Another thing I noticed is that the group is not announced correctly

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 a pull request may close this issue.

2 participants