From 3c9dc97e0f336570eea3c500a4244dcc2f9feb68 Mon Sep 17 00:00:00 2001 From: Jim Neuendorf Date: Wed, 12 Jun 2024 15:35:29 +0200 Subject: [PATCH] fix(pincode): avoid firing "complete" event on mount --- src/Pincode.svelte | 4 ++-- src/unstyled/Pincode.svelte | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Pincode.svelte b/src/Pincode.svelte index fb3d80b..f8a952e 100644 --- a/src/Pincode.svelte +++ b/src/Pincode.svelte @@ -72,7 +72,7 @@ focusNextInput(idx); }, add: (id, value) => { - let _code = [...code]; + const _code = [...code]; _ids.update((_) => { if (code[_.length] === undefined) { @@ -157,7 +157,7 @@ $: _type.set(type); $: _selectTextOnFocus.set(selectTextOnFocus); $: value = code.join(""); - $: complete = code.filter(Boolean).length === $_ids.length; + $: complete = code.length > 0 && code.filter(Boolean).length === $_ids.length; $: if (code) { _ids.update((_) => { return _.map((_id, i) => ({ ..._id, value: code[i] })); diff --git a/src/unstyled/Pincode.svelte b/src/unstyled/Pincode.svelte index a00a213..f30e9dd 100644 --- a/src/unstyled/Pincode.svelte +++ b/src/unstyled/Pincode.svelte @@ -72,7 +72,7 @@ focusNextInput(idx); }, add: (id, value) => { - let _code = [...code]; + const _code = [...code]; _ids.update((_) => { if (code[_.length] === undefined) { @@ -157,7 +157,7 @@ $: _type.set(type); $: _selectTextOnFocus.set(selectTextOnFocus); $: value = code.join(""); - $: complete = code.filter(Boolean).length === $_ids.length; + $: complete = code.length > 0 && code.filter(Boolean).length === $_ids.length; $: if (code) { _ids.update((_) => { return _.map((_id, i) => ({ ..._id, value: code[i] }));