I'm working on an Angular login page using Reactive Forms.
When the browser autofills saved username and password credentials, Angular doesn't always seem to detect the values immediately. As a result, my Login button remains disabled until the user interacts with the page.
I noticed that checking for browser autofill using selectors such as :-webkit-autofill appears to work in some browsers, but I'm unsure whether this is the recommended approach or if there's a better cross-browser solution.
How do you handle browser autofill in Angular Reactive Forms?
Specifically:
-
How do you detect when username and password fields have been autofilled by the browser?
-
How do you keep Reactive Forms synchronized with autofilled values?
-
Is relying on autofill selectors the correct approach?
-
What is the recommended solution for enabling/disabling a Login button when credentials are autofilled?
The application needs to support Chrome 90+, Edge 90+, Firefox 90+, and Safari 14+.
Any guidance or best practices would be appreciated.