Conditionally forward MenuItem click events only if the MenuItem is not disabled

This is obviously a lot easier in React, but at any rate this mimics upstream behavior here.
This commit is contained in:
Ryan Gossiaux
2021-12-28 09:03:43 -10:00
parent 2c09162fc0
commit d7348b35b6
2 changed files with 36 additions and 15 deletions

View File

@@ -8,7 +8,9 @@
import { forwardEventsBuilder } from "$lib/internal/forwardEventsBuilder";
import { get_current_component } from "svelte/internal";
import type { HTMLActionArray } from "$lib/hooks/use-actions";
const forwardEvents = forwardEventsBuilder(get_current_component());
const forwardEvents = forwardEventsBuilder(get_current_component(), [
{ name: "click", shouldExclude: () => disabled },
]);
export let as: SupportedAs = "a";
export let use: HTMLActionArray = [];
export let disabled = false;