anki/ts/deck-options/Label.svelte
Matthias Metelka fd2212a6cb
Prevent deck options switches from toggling on label click (#2166)
* Prevent deck options switches from toggling on label click

because the label click is reserved to open the help modal.

* Add option to prevent mouseclick event to Label.svelte
2022-11-04 10:06:57 +10:00

36 lines
708 B
Svelte

<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import { createEventDispatcher, onMount } from "svelte";
let forId: string;
export { forId as for };
export let preventMouseClick = false;
const dispatch = createEventDispatcher();
let spanRef: HTMLSpanElement;
onMount(() => {
dispatch("mount", { span: spanRef });
});
</script>
<label
bind:this={spanRef}
for={forId}
on:click={(e) => {
if (preventMouseClick) e.preventDefault();
}}
>
<slot />
</label>
<style lang="scss">
label {
display: inline;
}
</style>