Hello everyone,
I have been experimenting with Vaadin 10 for several days now, but I’m still pretty new to Vaadin Flow (and quite unfamiliar with the client side of things).
In our application we have a form containing a TextField
that requires the user to input a number. Validation and binding works flawlessly ; now I would like to set the HTML 5 <input>
's “type” attribute to “number” in order to facilitate input (particularily on mobile phones), and I cannot figure how.
-
Calling
textfield.getElement().setAttribute("type", "number")
sets the attribute on a parent<vaadin-text-field>
element, and not on the inner<input>
element ; -
It seems impossible to access the
TextField
’sElement
’s children (textfield.getElement().getChildCount()
always returns zero) ; -
Setting the “type” attribute works fine when using the [Element API]
(https://vaadin.com/docs/v10/flow/element-api/tutorial-properties-attributes.html) exclusively (by callingElementFactory.createInput()
and manipulating the result), but then we lose the ability to bind data since there’s noComponent
object.
So I’d like to ask the following questions :
-
Am I missing something ? Setting an
<input>
element’s “type” property would seem to me like a somewhat basic and frequent need… -
And if I’m not, and that is not possible as of yet, is there something planned that would allow it in the near future ?
-
And if there’s not, what would be the simplest way for me to achieve it ?
Looking at how other properties (like “autocorrect”) are set, I glanced at the client side ([vaadin-text-field.html]
(http://https://github.com/vaadin/vaadin-text-field/blob/master/src/vaadin-text-field.html)) and saw an<input>
element where several properties are defined (but not “type”). Would it be possible to create a component that somehow extends the existingTextField
by adding only this property ?
Thanks for your help.