[web] Autofill value of the focused field is lost when the form wakes up from dormant state

Đang mở
#196,974 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
dart, flutter
Lĩnh vực
frontend, web-dev

Hướng nghiên cứu

Start by tracing how Flutter web closes and restores the text input connection when focus is lost, then inspect how the dormant autofill form handles browser input and change events. Use the provided DevTools reproduction to confirm the behavior: after refocusing, the username input should remain the same element and retain its autofilled value, alongside the password.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

a: text input found in release: 3.47 found in release: 3.50 has reproducible steps platform-web team-web
Steps to reproduce

On Flutter web, a value the browser autofills into the field that was focused when the autofill form went dormant is thrown away when that field is focused again. Values autofilled into the other fields of the group are kept.

This happens with password managers that ask the user to authenticate before filling. The prompt takes focus away from the page, so the engine closes the text input connection and the autofill form goes dormant. The manager then fills the dormant form.

Minimal app:


import 'package:flutter/material.dart';

void main() => runApp(const MaterialApp(home: Scaffold(body: LoginForm())));

class LoginForm extends StatelessWidget {
  const LoginForm({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: SizedBox(
        width: 320,
        child: AutofillGroup(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: const [
              TextField(autofillHints: [AutofillHints.username]),
              TextField(autofillHints: [AutofillHints.password], obscureText: true),
            ],
          ),
        ),
      ),
    );
  }
}

With a real password manager (seen with , which asks for authentication before filling):

  1. Click the username field and pick a saved credential.
  2. The password manager shows its authentication prompt; authenticate.
  3. Pick the credential again.
  4. Only the password appears in the app. The username field stays empty.
  5. Reload the page and pick the credential (no authentication prompt this time). Both fields are filled.

Deterministic repro in the DevTools console, which simulates the same sequence:

  1. Click the username field.
  2. Run:

const u = document.getElementById('username');
const p = document.getElementById('current-password');
window.__u = u;
u.blur(); // window focus loss: relatedTarget == null -> connection closed, form goes dormant
const set = (el, v) => {
  Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set.call(el, v);
  el.dispatchEvent(new Event('input', {bubbles: true}));
  el.dispatchEvent(new Event('change', {bubbles: true}));
};
set(u, '[email protected]'); // browser autofills the dormant form
set(p, 'secret');

  1. Click the username field again.
  2. Run:

({sameUsername: document.getElementById('username') === __u,
  username: document.getElementById('username').value,
  password: document.getElementById('current-password').value})

Expected results

Both fields show the autofilled values after step 3.

Actual results

The password field shows secret. The username field is empty. The console prints {sameUsername: false, username: "", password: "secret"}: the username holding the autofilled value was replaced by a new, empty element.

Code sample
Code sample
import 'package:flutter/material.dart';

void main() => runApp(const MaterialApp(home: Scaffold(body: LoginForm())));

class LoginForm extends StatelessWidget {
  const LoginForm({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: SizedBox(
        width: 320,
        child: AutofillGroup(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: const [
              TextField(autofillHints: [AutofillHints.username]),
              TextField(autofillHints: [AutofillHints.password], obscureText: true),
            ],
          ),
        ),
      ),
    );
  }
}

Screenshots or Video
Screenshots / Video demonstration

[Upload media here]

Logs
Logs
[Paste your logs here]
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.47.9, on macOS 27.2 26B123 darwin-arm64, locale en-IL) [799ms]
    • Flutter version 3.47.9 on channel stable at /Users/iosiffuterman/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c197ca5199 (3 weeks ago), 2026-10-29 10:10:20 -0400
    • Engine revision 89c39edfdf
    • Dart version 3.13.7
    • DevTools version 2.60.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-record-use,
      enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [1,244ms]
    • Android SDK at /Users/iosiffuterman/Library/Android/sdk
    • Emulator version 37.2.13.0 (build_id 16740729) (CL:N/A)
    • Platform android-37, build-tools 36.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 25.0.3+-15898627-b508.16)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 27.1) [2.7s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 27A9275
    • CocoaPods version 1.17.0

[✓] Chrome - develop for the web [6ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Connected device (3 available) [6.7s]
    • iPhone Iosif Futerman (mobile) • 00008120-00181D0E0A70201E • ios            • iOS 18.6.2 22G100
    • macOS (desktop)                • macos                     • darwin-arm64   • macOS 27.2 26B123 darwin-arm64
    • Chrome (web)                   • chrome                    • web-javascript • Google Chrome 157.0.8103.79
    ! Error: Browsing on the local area network for Zalts iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources [599ms]
    • All expected network resources are available.

• No issues found!
Ngôn ngữ chính
Dart
Star
181k
Fork
32.2k
Merge trung bình
2 ngày 1 giờ
Pull request đã merge (30 ngày)
387

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của flutter/flutter

Tất cả issue của flutter/flutter

Issue tương tự

Thêm issue về Dart

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.