vaadin / web-components

A set of high-quality standards based web components for enterprise web applications. Part of Vaadin 20+
https://vaadin.com/docs/latest/components
447 stars 83 forks source link

[number-field] Consider using `input type="text"` for number and integer fields #3102

Open sissbruecker opened 2 years ago

sissbruecker commented 2 years ago

Describe your motivation

Currently vaadin-number-input internally uses an input type="number" element. That comes with a lot of benefits, such as supporting localized number formats out of the box, preventing entering non-numeric characters, stepper controls, or displaying an appropriate on-screen keyboard layout on mobile devices. However the approach also has downsides, in that all the above points do not work consistently between browsers, devices, and locales. Another issue is that a number type input does not allow much flexibility, for example when it comes the presentation number format, or when dealing with the stepper buttons. Other component libraries have chosen to implement their number field component using an input type="text" instead, by reimplementing some or all of the native behaviour of the native number type input. We can consider doing the same for our vaadin-number-input. This ticket is about collecting the benefits that we would gain from such a change, and also about noting down which behaviour we would have to replicate from the native number input if we decide to move ahead with this.

What could we gain from it

What behaviour would we have to reimplement, what do we need to look out for

Additional context

We should take a look at existing component libraries, which have implemented such an approach, and have worked out most of the kinks. Some notable examples:

jorgheymans commented 9 months ago

If you need more weight to put this on your roadmap: Vaadin puts itself mostly in the niche of business applications. Such applications very often deal with amounts, so i think Vaadin could have built-in first class support for entering, displaying, and binding such data in all aspects.