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] }));