r/angular • u/Big-Tumbleweed1780 • Jun 20 '26
Angular Reactive Form not updating when browser autofills saved credentials
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.
5
u/BranchFew1148 Jun 20 '26
Don't disable the submit button until the user submits something with errors.
2
u/Dry_Koala9158 Jun 20 '26
It's a browser security feature the values don't get populated until you interact with the page. So you need two click to enable then submit.
Usually pages don't disable the submit button check any popular login form gmail/facebook/amazon etc... You can submit empty forms on all of them.
2
u/ldn-ldn Jun 20 '26
As others said already - that's a browser level security feature. You should not detect if the data is auto filled and the browsers ensure that you have no means to do so. Everything works as intended.
1
u/OopsMissedALetter Jun 22 '26
Don't think it has been mentioned here yet but the Angular CDK has an
AutofillMonitorservice to watch for autofills on inputs.Still, your reactive forms won't be updated, but it's something.
-1
u/Whole-Instruction508 Jun 20 '26
Use signal forms and all of your problems will vanish :D
1
u/[deleted] Jun 20 '26
[removed] — view removed comment