aha
aha

Reputation: 33

Vaadin Flow: Browser does not save passwod

After migrating from Vaadin 8 to 14, browsers do not remember password. With some googling, the below link gives a solution, but I don't understand exactly what I need to do.

https://vaadin.com/forum/thread/17399734/leverage-browser-save-password-feature

Jouni Koivuviita said:

Vaadin input field components have a feature that allows you 
to slot in a native input element, and thereby allow password managers to work (assuming you 
do not have any other shadow roots in your DOM in the hierarchy above the input field).

    <vaadin-text-field>
        <input type="text" slot="input">
    </vaadin-text-field>

How is this solution implemented in Java exactly ?

Thanks for help.

Upvotes: 0

Views: 76

Answers (1)

Leif &#197;strand
Leif &#197;strand

Reputation: 8001

There are two "easy" solutions:

  • Use the built-in login component that handles this automatically
  • Upgrade to Vaadin 23 where the text field workaround is no longer needed

For the difficult solution, you need to use some low-level APIs to make the Java part of Flow replicate the HTML example that you quoted. It goes something like this:

TextField field = new TextField();
Element input = new Element("input");
input.setAttribute("slot", "input");
field.getElement().appendChild(input);

Upvotes: 2

Related Questions