pacocoursey / cmdk

Fast, unstyled command menu React component.
https://cmdk.paco.me
MIT License
9.42k stars 265 forks source link

[Accessibility] `aria-selected=false` never happens #83

Closed prestonbourne closed 6 months ago

prestonbourne commented 1 year ago

https://github.com/pacocoursey/cmdk/blob/abe6b2460dd896447f715c678b623f17366762b9/cmdk/src/index.tsx#L613-L615

Since we're using || if selected or disabled returns false, the entire aria label will be undefined.

We would prefer aria-label=false to be the case so that someone relying on the labels see's that it isnt selected but can be. Right now the only possible state is aria-selected=true

We can fix this by migrating from the || operator to the nullish ?? operator