Skip to content

[web] Fix grouped autofill on iOS Chrome#187459

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
flutter-zl:issue_185327_chrome_autofill
Jul 8, 2026
Merged

[web] Fix grouped autofill on iOS Chrome#187459
auto-submit[bot] merged 3 commits into
flutter:masterfrom
flutter-zl:issue_185327_chrome_autofill

Conversation

@flutter-zl

@flutter-zl flutter-zl commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #185327

Problem

On iOS Chrome, Chrome Password Manager did put the saved password into Flutter Web's hidden browser input. But Flutter Web still thought the password field was empty, so when it refreshed the autofill form, it copied that old empty value back into the browser input. The password was erased before it showed up in the visible Flutter TextField.

Fix

Before copying Flutter's stored value into a non-focused autofill field, Flutter Web now checks what is already in the browser input. If the browser input already has a password that Flutter has not seen yet, Flutter Web sends that password to the framework and leaves the browser input alone instead of clearing it.

To avoid mistaking a deliberate app change for an autofill, it tracks the last framework value for each field, carried
over when the autofill form is reused. A value the app changed programmatically is still pushed into the DOM; only an
unchanged framework value sitting next to a changed DOM value is treated as a browser autofill.

Demo

iOS Chrome:

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 2, 2026
@github-actions github-actions Bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine related. See also e: labels. platform-web Web applications specifically and removed CICD Run CI/CD labels Jun 2, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 2, 2026
@github-actions github-actions Bot removed the framework flutter/packages/flutter repository. See also f: labels. label Jun 2, 2026
@flutter-zl flutter-zl force-pushed the issue_185327_chrome_autofill branch from ba013ff to 2f7a634 Compare June 2, 2026 22:26
@github-actions github-actions Bot added e: impeller Impeller rendering backend issues and features requests and removed CICD Run CI/CD labels Jun 2, 2026
@flutter-zl flutter-zl force-pushed the issue_185327_chrome_autofill branch from 2f7a634 to dd78fad Compare June 2, 2026 22:27
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 2, 2026
@github-actions github-actions Bot removed the e: impeller Impeller rendering backend issues and features requests label Jun 2, 2026
@flutter-zl flutter-zl marked this pull request as ready for review June 12, 2026 17:57
@flutter-zl flutter-zl requested a review from mdebbar June 12, 2026 18:00

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces tracking of the last sent autofill text to preserve dormant autofill values when a form is restored, along with a corresponding test. The review feedback identifies a potential regression where programmatic updates from the framework to non-focused fields could be ignored or reverted, and suggests tracking the last processed framework text to distinguish between programmatic updates and browser autofill events.

@github-actions github-actions Bot added team-web Owned by Web platform team and removed CICD Run CI/CD labels Jun 12, 2026
@flutter-zl flutter-zl force-pushed the issue_185327_chrome_autofill branch from 3162f92 to b65c116 Compare June 12, 2026 18:57
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jun 12, 2026
@mdebbar

mdebbar commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

The symptoms sound very similar to this issue: #177248

When the hidden input's value is updated, does it receive focus first or does it get updated without a focus event?

@flutter-zl

Copy link
Copy Markdown
Contributor Author

The symptoms sound very similar to this issue: #177248

When the hidden input's value is updated, does it receive focus first or does it get updated without a focus event?

  1. I measured it on a real iOS Chrome device with a focusin/input probe: the hidden password input is updated
    without a focus event. The browser fires input and change on it while document.activeElement stays on
    the focused username field, and no focusin ever lands on the password field.

  2. Different failure mode from [web] Autofill does not work on browsers running on iOS 26 and iPadOS 26 devices #177248 though. That one is total autofill failure on iOS 26 across browsers; here autofill partially works, the focused username fills but the non-focused password is lost on iOS Chrome, while iOS Safari fills both.

@mdebbar

mdebbar commented Jun 15, 2026

Copy link
Copy Markdown
Contributor
  1. the hidden password input is updated
    without a focus event. The browser fires input and change on it while document.activeElement stays on
    the focused username field, and no focusin ever lands on the password field.

This case is supposed to be handled by:

subscriptions.add(
DomSubscription(
element,
'input',
createDomEventListener((DomEvent e) {
if (items[key] == null) {
throw StateError('AutofillInfo must have a valid uniqueIdentifier.');
} else if (key != focusedElementId) {
// `input` events on the focused element are handled elsewhere.
final AutofillInfo autofillInfo = items[key]!.autofillInfo;
_handleChange(element, autofillInfo);
}
}),
),
);

@flutter-zl

Copy link
Copy Markdown
Contributor Author
  1. the hidden password input is updated
    without a focus event. The browser fires input and change on it while document.activeElement stays on
    the focused username field, and no focusin ever lands on the password field.

This case is supposed to be handled by:

subscriptions.add(
DomSubscription(
element,
'input',
createDomEventListener((DomEvent e) {
if (items[key] == null) {
throw StateError('AutofillInfo must have a valid uniqueIdentifier.');
} else if (key != focusedElementId) {
// `input` events on the focused element are handled elsewhere.
final AutofillInfo autofillInfo = items[key]!.autofillInfo;
_handleChange(element, autofillInfo);
}
}),
),
);

Yes, that path should handle non-focused input events while the form is active.

The difference here is timing: in this repro, the password appears to be written after DefaultTextEditingStrategy.disable() has canceled the autofill input subscriptions, but while goDormant() keeps the form in the DOM for browser autofill. So the DOM input gets the password, but Flutter no longer has that listener attached to call _handleChange.

Then when the dormant form is reused, wakeUp() calls _updateFieldValues(), which previously copied the framework's stale empty value back into the non-focused password input.

@flutter-zl flutter-zl requested review from harryterkelsen and removed request for mdebbar July 1, 2026 17:49

@harryterkelsen harryterkelsen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@flutter-zl flutter-zl added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 7, 2026
@auto-submit

auto-submit Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/187459, because The base commit of the PR is older than 7 days and can not be merged. Please merge the latest changes from the main into this branch and resubmit the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems CICD Run CI/CD engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-web Owned by Web platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[web] Flutter Webapp on Mobile Device Chrome Browser unable to autofill with Chrome Password Manager

3 participants