@@ -1,18 +1,19 @@
|
||||
<script lang="ts">
|
||||
import { getContext } from "svelte";
|
||||
import { ListboxStates, useListboxContext } from "./Listbox.svelte";
|
||||
import { useId } from "$lib/hooks/use-id";
|
||||
let api = useListboxContext("ListboxLabel");
|
||||
let id = `headlessui-listbox-label-${useId()}`;
|
||||
let labelStore: SvelteStore<HTMLLabelElement> = getContext("labelStore");
|
||||
let api = useListboxContext("ListboxLabel");
|
||||
|
||||
function handleClick() {
|
||||
$api.buttonRef?.focus({ preventScroll: true });
|
||||
let labelRef = $api.labelRef;
|
||||
let buttonRef = $api.buttonRef;
|
||||
|
||||
function handleClick(): void {
|
||||
$buttonRef?.focus({ preventScroll: true });
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y-label-has-associated-control -->
|
||||
<label {...$$restProps} {id} bind:this={$labelStore} on:click={handleClick}>
|
||||
<label {...$$restProps} {id} bind:this={$labelRef} on:click={handleClick}>
|
||||
<slot
|
||||
open={$api.listboxState === ListboxStates.Open}
|
||||
disabled={$api.disabled}
|
||||
|
||||
Reference in New Issue
Block a user