Skip to content

[web] Keep live autofill form across TextInput.updateConfig - #194015

Closed
flutter-zl wants to merge 2 commits into
flutter:masterfrom
flutter-zl:issue_192544_fix
Closed

flutter-zl wants to merge 2 commits into
flutter:masterfrom
flutter-zl:issue_192544_fix

Conversation

@flutter-zl

@flutter-zl flutter-zl commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #192544
Fixes #192102

Problem

On web, a focused autofill TextField that receives TextInput.updateConfig, for example from an obscureText toggle, stops accepting input for good. The engine swaps in a new EngineAutofillForm that was never woken up, so on blur disable() removes the editing element instead of keeping the form dormant, and later sessions swap the new element into a node that is no longer in the DOM. The same mismatch makes the next geometry update build a second form, which can end in the null check crash reported in the comments.

Fix

TextInputUpdateConfig now hands the live form's DOM and per-field tracking to the new form when both have the same formIdentifier, reusing the adoption logic wakeUp() already had. Field values and attributes from the update still apply. An update that changes the set of fields keeps the old behavior.

Demo

Before: https://flutter-demo-74-before.web.app
After: https://flutter-demo-74-after.web.app

Wait about 4 seconds for the scripted focus steps to finish, then click Field A and type. Before: Field A shows a caret but accepts no input. After: Field A accepts input.

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Oct 8, 2026
@github-actions github-actions Bot added a: text input Entering text in a text field or keyboard related problems engine flutter/engine related. See also e: labels. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) platform-web Web applications specifically team-web Owned by Web platform team labels Oct 8, 2026

@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 refactors EngineAutofillForm by extracting form adoption logic into a private _adopt method and updates TextInputUpdateConfig.run to reuse the live form when configuration updates occur with the same form identifier. It also adds regression tests to verify that fields remain editable and forms are correctly managed during updates. The review feedback suggests removing a redundant null assertion operator (!) on liveForm in TextInputUpdateConfig.run because it is already promoted to a non-nullable type.

// blur cannot put it to sleep and the next placement builds a second form.
if (liveForm?.formElement != null &&
newForm != null &&
newForm.formIdentifier == liveForm!.formIdentifier) {

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.

medium

Since liveForm is a local final variable and we have already checked liveForm?.formElement != null in the condition, liveForm is promoted to a non-nullable type by Dart's flow analysis. The null assertion operator (!) is redundant here and can be safely removed.

Suggested change
newForm.formIdentifier == liveForm!.formIdentifier) {
newForm.formIdentifier == liveForm.formIdentifier) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We need to keep the !. Checking liveForm?.formElement != null does not tell Dart that liveForm itself is not null. Without the !, the code does not compile.

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

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) 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

1 participant