TextField Browser AutoFill

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");

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

18511467.png

Thank you, that helped! For the record, my Java code is:

input.getElement().setAttribute("name", "email");
input.setAutocomplete(Autocomplete.EMAIL);

Regards,
Ulrich