ui icon indicating copy to clipboard operation
ui copied to clipboard

Unclearable NaN value in NumberInput example

Open vasilii-kovalev opened this issue 5 years ago • 1 comments

Steps to reproduce:

  1. Go to https://sveltekit.now.sh/#NumberInput
  2. Focus on the input element and clear the value by pressing Backspace button

Actual behavior: NaN value is displayed and can't be cleared/changed even with increase/decrease buttons (arrows).

Expected behavior: value is cleared.

image

vasilii-kovalev avatar Sep 12 '20 21:09 vasilii-kovalev

It seems that's because isFinite('') is true: https://github.com/sveltekit/ui/blob/41a6cd96f17eb98cedbafbaca97b8e50252f60a7/src/components/NumberInput/NumberInput.svelte#L25-L27

so it is casted to float: https://github.com/sveltekit/ui/blob/41a6cd96f17eb98cedbafbaca97b8e50252f60a7/src/components/NumberInput/NumberInput.svelte#L33-L35

Actually, unit tests could help to catch this issue. I personally know about Svelte Testing Library, maybe there is something else.

vasilii-kovalev avatar Sep 12 '20 22:09 vasilii-kovalev