flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.71k stars 27.36k forks source link

iOS Autofill "hide my email" does not work #157495

Open just-doit opened 1 day ago

just-doit commented 1 day ago

Steps to reproduce

  1. Use provided sample code (or build a simple app with a TextField)
  2. Run app
  3. Tap on text field
  4. Tap on "Hide My Email"
  5. Create a new "Hide My Email" address (or use the existing)

Expected results

I expect the TextField to be filled with the created / selected email address.

Actual results

The TextField stays empty.

Code sample

Code sample ```dart import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( title: 'Test', home: DetailPage(), ); } } class DetailPage extends StatefulWidget { const DetailPage({super.key}); @override State createState() => _DetailPageState(); } class _DetailPageState extends State { final TextEditingController _emailController = TextEditingController(); @override void dispose() { _emailController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: Form( child: CupertinoFormSection.insetGrouped( header: const Text('EMAIL'), children: [ CupertinoTextFormFieldRow( controller: _emailController, prefix: Icon(CupertinoIcons.mail, color: CupertinoColors.label.resolveFrom(context)), keyboardType: TextInputType.emailAddress, autofillHints: const [AutofillHints.email], ) ], ), ), ), ); } } ```

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.24.0, on macOS 15.0.1 24A348 darwin-arm64, locale de-DE) • Flutter version 3.24.0 on channel stable at /Users/dirkmika/projects/SDKs/Flutter/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 80c2e84975 (3 months ago), 2024-07-30 23:06:49 +0700 • Engine revision b8800d88be • Dart version 3.5.0 • DevTools version 2.37.2 [!] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/dirkmika/Library/Android/sdk ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/to/macos-android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 16.0) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 16A242d • CocoaPods version 1.15.2 [✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [✓] Android Studio (version 2023.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314) [✓] VS Code (version 1.94.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.98.0 [✓] Connected device (3 available) • Mein 13 Pro (mobile) • 00008110-000A34300C62801E • ios • iOS 18.0.1 22A3370 • macOS (desktop) • macos • darwin-arm64 • macOS 15.0.1 24A348 darwin-arm64 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.0.1 24A348 darwin-arm64 [✓] Network resources • All expected network resources are available. ! Doctor found issues in 2 categories. ```
huycozy commented 1 day ago

Hi @just-doit Unfortunately, I don't have a device that subscribe to iCloud+ to have Hide My Email feature. From my understanding, the anonymous/generated account is not auto-filled when you tap again on the fields, correct?

Can you please check this behavior on iOS native TextField?

just-doit commented 1 day ago

Normally, you tap on “Hide My Email” and a sheet opens, which in my case shows that I have already generated an address for the app. I then tap on “Continue” so that the sheet disappears again. The email address should then be inserted into the text field.

In addition to the fact that no text appears in the text field, it is also noticeable that the text field no longer has focus (the cursor has disappeared), but the keyboard is still open. It seems the text field looses focus as soon as "Hide My Email" is selected.

See attached video (this is a native TextField):

https://github.com/user-attachments/assets/b9434c48-9a78-4c10-9517-a271deb2aafe

huycozy commented 23 hours ago

Thank you for the demo video. But I'm confused since you mentioned it's on a native TextField and I see the issue also appeared, right?

just-doit commented 22 hours ago

Sorry, I think I misunderstood you. I thought it was about the two flutter classes CupertinoTextFormFieldRow vs TextField. The source code says CupertinoTextFormFieldRow while for the video I used a TextField.

But you probably mean a SwiftUI TextField. I have tested this with the following code and it works as expected:

import SwiftUI

struct ContentView: View {
    @State var text: String = ""

    var body: some View {
        TextField("EMail", text: $text)
            .textContentType(.emailAddress)
    }
}

https://github.com/user-attachments/assets/61e261b0-7742-4a60-b3d3-1b1311747fe3

huycozy commented 22 hours ago

Thanks for confirming this. It makes sense now. Labeling this for further investigation.