Closed davidkpiano closed 1 year ago
It's not just that example either:
https://user-images.githubusercontent.com/248587/207175507-8b303660-cb3a-4326-96cb-713c0d7562d7.mov
aria-selected
itemStep 1: Create a reference to the command
const cmdref = useRef<any>(null)
<Command
// ...
ref={cmdref}
>
// ...
<Command.Item value="target">
target
</Command.Item>
</Command>
Step 2: Access the value of the command when needed:
const val = cmdref.current.querySelector(`[cmdk-item=""][aria-selected="true"]`).dataset.value
// val = "target"
Discovered this when narrowing the input to select only one value, and noticed that the right area didn't change:
https://user-images.githubusercontent.com/1093738/205722637-4a2802d2-c239-4de9-b66f-cbe37d509536.mp4