Add title/tooltip to LoginForm forgotPasswordButton in Vaadin23

Hi I want to add a tooltip text to the password forgotten button within the vaadin login form.

I tried to set it via:

String jsExpression = String.format(“document.getElementById(‘forgotPasswordButton’).title=‘%s’;”,tooltipText);
getElement().executeJs(jsExpression);

but that does not work.

document.getElementById(‘forgotPasswordButton’); returns null for whatever reason so no wonder it is not working, any suggestion how to set the title to this button?

Hi, if you check the dom the button is inside the shadow root of the login form, so you need to consider that. This worked for me:

                .executeJs(
                        "document.getElementsByTagName('vaadin-login-form-wrapper')[0].shadowRoot.getElementById('forgotPasswordButton').title = $0;",
                        "I'm the title of forgot password button"); 

@perfect-raccoon Thanks that was it, I am not to familiar with shadow root currently but will consider this in the future.