Ulrich.1
(Ulrich Mayring)
January 12, 2021, 10:41am
1
Hello,
I have a TextField, but the browser (Firefox) doesn’t remember the values I put in. How can I get Browser AutoFill to work on this?
The code I have is basically this:
TextField input = new TextField();
input.setId("email");
input.setPlaceholder("E-Mail Address");
web-padawan
(Serhii Kulykov)
January 13, 2021, 8:37am
2
Hello, in order to get autocomplete working, you need to set name
and autocomplete
attributes.
So the HTML would look like this:
<vaadin-email-field label="Email" name="email" autocomplete="email"></vaadin-email-field>
Please see the screenshot in the attachment: the browser autofill popup is there (after I click the field twice).
I do not use Firefox regularly so apparently it did not have stored emails and shows phone instead.
In Chrome with the same configuration I got the list of emails displayed properly.
See also https://stackoverflow.com/questions/7223168/how-to-trigger-autofill-in-google-chrome/41965106#41965106
Ulrich.1
(Ulrich Mayring)
January 13, 2021, 8:59am
3
Thank you, that helped! For the record, my Java code is:
input.getElement().setAttribute("name", "email");
input.setAutocomplete(Autocomplete.EMAIL);
Regards,
Ulrich