Closed rbauduin closed 6 months ago
@rbauduin Sorry for sitting on this for ages. I just had a quick check with @Jooseppi12, and we found that according to the HTML5 spec's 4.10.7.1.13 Number state section, "If the value of the element is not a valid floating point number, then set it to the empty string instead."
This pretty much means that UI couldn't return what was entered, because it has no access to it (and the user agent shouldn't even allow entering incorrect numbers in the first place.) Given that this is a grey area, I'd recommend using an ordinary string input field and doing manual number parsing. You could save the parsing bit by using an additional "shadow" (=hidden) number input element and reflect the value entered into the text input element into it. This way you can read the parsed/sanitized number value back from that, instead of the text element.
As discussed with @granicz on Slack some time ago. See it in action at https://try.websharper.com/snippet/0000Zh It should not wrap an empty string, but the value entered by the user.