Making sure checkbox input is clickable without following the link

This commit is contained in:
koloml committed 2025-02-18 01:17:43 +04:00
1 parent dff77391b0
commit 62857d44c2
1 file changed
+6 -1
@@ -22,10 +22,15 @@
onclick,
oninput,
}: MenuCheckboxItemProps = $props();
function stopPropagationAndPassCallback(originalEvent: MouseEvent) {
originalEvent.stopPropagation();
onclick?.(originalEvent as MouseEvent & { currentTarget: HTMLInputElement });
}
</script>
<MenuLink {href}>
<input bind:checked={checked} {name} {onclick} {oninput} type="checkbox" {value}>
<input bind:checked={checked} {name} onclick={stopPropagationAndPassCallback} {oninput} type="checkbox" {value}>
{@render children?.()}
</MenuLink>