finput icon indicating copy to clipboard operation
finput copied to clipboard

Pasting a value containing a space results in NaN (or error in IE11)

Open ryanggrey opened this issue 8 years ago • 4 comments

Reported by user. I haven't tried replicating this. Probably worth checking if issue exists in other browsers too.

ryanggrey avatar Jul 10 '17 13:07 ryanggrey

In helpers.parseString each character of a pasted string is checked to see if it is a number or not. Confusingly isNaN(' ') returns false, i.e. ' ' is a number. MDN has a list of exmaples of things that are considered numbers.

Leading and trailing spaces are kept in the string when trying to parse it as a number, but these don't cause any issues, only spaces in the middle.

What should the behaviour be here? Should pasting 1 23.45 be 123.45, 1, invalid?

Slightly related - when pasting 12.34.56, this gets parsed as 12.34.

ggovan avatar Jul 13 '17 10:07 ggovan

Looks like this has been fixed in 1.1.1. Pasting 12.34.56 still gives 12.34, but I can live with that.

ggovan avatar Jul 19 '17 15:07 ggovan

Related - pasting 1a2b3c4d gives 1,234,000,000,000.00

ggovan avatar Jul 20 '17 09:07 ggovan

Pasting te xt or any text with spaces gives 0.00.

ggovan avatar Jul 20 '17 10:07 ggovan