mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
fix(toggle): avoid dispatching toggle
event on state change (#2184)
This commit is contained in:
parent
94b4e30e26
commit
0df727b704
1 changed files with 2 additions and 2 deletions
|
@ -39,8 +39,6 @@
|
|||
import { createEventDispatcher } from "svelte";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
$: dispatch("toggle", { toggled });
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
||||
|
@ -63,12 +61,14 @@
|
|||
checked={toggled}
|
||||
on:change={() => {
|
||||
toggled = !toggled;
|
||||
dispatch("toggle", { toggled });
|
||||
}}
|
||||
on:change
|
||||
on:keyup={(e) => {
|
||||
if (e.key === " " || e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
toggled = !toggled;
|
||||
dispatch("toggle", { toggled });
|
||||
}
|
||||
}}
|
||||
on:keyup
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue