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
This commit is contained in:
Matthias Metelka 2022-11-04 01:06:57 +01:00 committed by GitHub
parent dba4925aba
commit fd2212a6cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -7,6 +7,7 @@
let forId: string;
export { forId as for };
export let preventMouseClick = false;
const dispatch = createEventDispatcher();
@ -17,7 +18,15 @@
});
</script>
<label bind:this={spanRef} for={forId}><slot /></label>
<label
bind:this={spanRef}
for={forId}
on:click={(e) => {
if (preventMouseClick) e.preventDefault();
}}
>
<slot />
</label>
<style lang="scss">
label {

View file

@ -17,7 +17,7 @@
</script>
<Row --cols={6}>
<Col --col-size={4}><Label for={id}><slot /></Label></Col>
<Col --col-size={4}><Label for={id} preventMouseClick><slot /></Label></Col>
<Col --col-justify="flex-end">
<ConfigInput grow={false}>
<Switch {id} bind:value />