pacocoursey / cmdk

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

Aria-Expanded true on Input? #316

Open zachlankton opened 1 month ago

zachlankton commented 1 month ago

Hello! Love your project!

what is the purpose of aria-expanded on the input?

https://github.com/pacocoursey/cmdk/blob/92344c58a63b995f6eb149245c56ea548540dd18/cmdk/src/index.tsx#L808

I have an edge case where I'm looking for aria-expanded attributes to determine if there are popovers open while inside of a dialog.

In these cases I handle the escape key to close the popover and not the dialog.

This works fantastic when I render CMDK inside a combobox like shadcn combobox.

But when I use CMDK (Command in Shadcn) inline directly inside a modal my escape key functionality is not workin as expected because aria-expanded is set to true on the input.

This seems a little strange to me as the control is rendered in line and is not actually "expanded".

I realize this must be an incredibly arcane and strange edge case, but I'm curious to know why the decision was made to make aria-expanded true regardless of any expanded context or control?

And also... would you be open to make this property available to be over-ridden via props? 😊

Willing to contribute here if needed!