Fix listbox label ref
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
let id = `headlessui-listbox-button-${useId()}`;
|
let id = `headlessui-listbox-button-${useId()}`;
|
||||||
let buttonRef = $api.buttonRef;
|
let buttonRef = $api.buttonRef;
|
||||||
let optionsRef = $api.optionsRef;
|
let optionsRef = $api.optionsRef;
|
||||||
|
let labelRef = $api.labelRef;
|
||||||
|
|
||||||
async function handleKeyDown(event: KeyboardEvent) {
|
async function handleKeyDown(event: KeyboardEvent) {
|
||||||
switch (event.key) {
|
switch (event.key) {
|
||||||
@@ -65,9 +66,7 @@
|
|||||||
"aria-expanded": $api.disabled
|
"aria-expanded": $api.disabled
|
||||||
? undefined
|
? undefined
|
||||||
: $api?.listboxState === ListboxStates.Open,
|
: $api?.listboxState === ListboxStates.Open,
|
||||||
"aria-labelledby": $api?.labelRef
|
"aria-labelledby": $labelRef ? [$labelRef?.id, id].join(" ") : undefined,
|
||||||
? [$api?.labelRef?.id, id].join(" ")
|
|
||||||
: undefined,
|
|
||||||
disabled: $api?.disabled === true ? true : undefined,
|
disabled: $api?.disabled === true ? true : undefined,
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user