Disable paste event on PasswordField

Hi,

How to disable paste event on PasswordField in Vaadin 14? The copy event is disabled by default, and I would like to disable the paste event.

Looking forward to your suggestions.
Thanks,
Stefan

Are you really sure you want to disable pasting values into password fields?

This idea has previously been considered a good practice for security but nowadays basically any security expert will say that it’s a bad idea because of how it makes it difficult to use a password manager. See e.g. https://www.troyhunt.com/the-cobra-effect-that-is-disabling/ for more details.

As Leif mentioned it could cause problems with the password managers and usability. There is no API for that one in the component, however the way to do it would be:
passwordField.getElement().setAttribute("onpaste", "return false;");

As a beginner in Vaadin framework, I needed this for testing purposes. Thanks for the reply and for the post, I have found it very useful.