Skip to content

Flutter Web (Chrome browser) - TextFormField losing focus after it goes to background, for example on a tab switch #178109

Closed

Description

@vikasdwivedi-kuhoo

Steps to reproduce

Start typing inside a TextFormField, go to a different tab and come back, it will lose focus.

Expected results

TextFormField should regain focus after the Web application is in foreground. This started happening after we updated to 3.35.0

Actual results

TextFormField loses focus

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Activity

  1. ulisseshen commented on Nov 6, 2025

    @ulisseshen
    Contributor

    Should you provide Flutter Doctor output and also a minimum reproducible example that what are you facing?

  2. vikasdwivedi-kuhoo commented on Nov 6, 2025

    @vikasdwivedi-kuhoo
    Author

    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel stable, 3.35.0, on macOS 26.0.1 25A362 darwin-arm64, locale en-IN)
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    [✓] Xcode - develop for iOS and macOS (Xcode 26.0.1)
    [✓] Chrome - develop for the web
    [✓] Android Studio (version 2024.1)
    [✓] VS Code (version 1.95.3)

    @ulisseshen Flutter doctor summary
    On Web we use TextFormField. Our users copy text from a file and try to paste it in our TextFormField, but it loses focus as soon as they switch the tab or minimize our Web App on Chrome browser.

  3. changed the title [-]Flutter Web - TextFormField losing focus after it goes to background, for example on a tab switch[/-] [+]Flutter Web (Chrome browser) - TextFormField losing focus after it goes to background, for example on a tab switch[/+] on Nov 6, 2025
  4. danagbemava-nc commented on Nov 7, 2025

    @danagbemava-nc
    Member

    Hi @vikasdwivedi-kuhoo, thanks for filing this issue. To make it easier for us to determine what broke this behavior, kindly tell us which version of flutter you were on before you upgraded to 3.35.0

    Thank you

  5. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Nov 7, 2025
  6. vikasdwivedi-kuhoo commented on Nov 7, 2025

    @vikasdwivedi-kuhoo
    Author

    @danagbemava-nc Our previous version was 3.29.3, Just fyi this is working fine on Firefox and Safari.

  7. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Nov 7, 2025
  8. danagbemava-nc commented on Nov 10, 2025

    @danagbemava-nc
    Member

    Reproducible using the steps outlined above. Can confirm this is a regression as it worked as expected on stable 3.32.8 but not the latest stable & master.

    In my testing, it appeared to work on Safari but not Firefox and Chrome.

    Bisected this to #166804

    Labeling this for further insight

    3.32.8 3.35.0+
    Screen.Recording.2025-11-10.at.6.28.52.AM.mov
    Screen.Recording.2025-11-10.at.6.29.49.AM.mov
    code sample
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'TextFormField Focus Issue #178109',
          home: Scaffold(
            appBar: AppBar(title: const Text('TextFormField Focus Test')),
            body: Center(
              child: SizedBox(
                width: 300,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    const Text('1. Click and type in the field below'),
                    const Text('2. Switch to another browser tab'),
                    const Text('3. Switch back to this tab'),
                    const Text('4. Notice: Focus is lost (bug)'),
                    const SizedBox(height: 20),
                    TextFormField(
                      decoration: const InputDecoration(
                        labelText: 'Type here',
                        border: OutlineInputBorder(),
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
        );
      }
    }
    flutter doctor -v
    [!] Flutter (Channel [user-branch], 3.32.8, on macOS 26.2 25C5031i darwin-arm64, locale en-US) [739ms]
        ! Flutter version 3.32.8 on channel [user-branch] at /Users/deanli/dev/switcher
          Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
          If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
        ! Warning: `flutter` on your path resolves to /Users/deanli/dev/stable/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/deanli/dev/switcher. Consider adding /Users/deanli/dev/switcher/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/deanli/dev/stable/bin/dart, which is not inside your current Flutter SDK checkout at /Users/deanli/dev/switcher. Consider adding /Users/deanli/dev/switcher/bin to the front of your path.
        ! Upstream repository unknown source is not a standard remote.
          Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
        • Framework revision edada7c56e (4 months ago), 2025-07-25 14:08:03 +0000
        • Engine revision ef0cd00091
        • Dart version 3.8.1
        • DevTools version 2.45.1
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [1,797ms]
        • Android SDK at /Users/deanli/Library/Android/sdk
        • Platform android-36.1, build-tools 36.1.0
        • Java binary at: /Users/deanli/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 21.0.8+-14196175-b1038.72)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 26.2) [1,316ms]
        • Xcode at /Applications/Xcode-26.2.0-beta.app/Contents/Developer
        • Build 17C5013i
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [11ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2025.2) [11ms]
        • Android Studio at /Users/deanli/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 21.0.8+-14196175-b1038.72)
    
    [✓] VS Code (version 1.105.1) [10ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.122.0
    
    [✓] Connected device (4 available) [7.4s]
        • Dean iPad (wireless) (mobile) • 00008103-000825C811E3401E • ios            • iOS 26.1 23B5059e
        • iPhone 16 Pro Max (mobile)    • 00008140-00194CC23A68801C • ios            • iOS 26.1 23B82
        • macOS (desktop)               • macos                     • darwin-arm64   • macOS 26.2 25C5031i darwin-arm64
        • Chrome (web)                  • chrome                    • web-javascript • Google Chrome 142.0.7444.135
        ! Error: Browsing on the local area network for Nexus. 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 [762ms]
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
    
    [✓] Flutter (Channel stable, 3.35.7, on macOS 26.2 25C5031i darwin-arm64, locale en-US) [641ms]
        • Flutter version 3.35.7 on channel stable at /Users/deanli/dev/stable
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision adc9010625 (3 weeks ago), 2025-10-21 14:16:03 -0400
        • Engine revision 035316565a
        • Dart version 3.9.2
        • DevTools version 2.48.0
        • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-lldb-debugging
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [1,712ms]
        • Android SDK at /Users/deanli/Library/Android/sdk
        • Emulator version 36.2.12.0 (build_id 14214601) (CL:N/A)
        • Platform android-36.1, build-tools 36.1.0
        • Java binary at: /Users/deanli/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 21.0.8+-14196175-b1038.72)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 26.2) [1,357ms]
        • Xcode at /Applications/Xcode-26.2.0-beta.app/Contents/Developer
        • Build 17C5013i
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [6ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2025.2) [6ms]
        • Android Studio at /Users/deanli/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 21.0.8+-14196175-b1038.72)
    
    [✓] VS Code (version 1.105.1) [5ms]
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.122.0
    
    [✓] Connected device (4 available) [7.4s]
        • Dean iPad (wireless) (mobile) • 00008103-000825C811E3401E • ios            • iOS 26.1 23B5059e
        • iPhone 16 Pro Max (mobile)    • 00008140-00194CC23A68801C • ios            • iOS 26.1 23B82
        • macOS (desktop)               • macos                     • darwin-arm64   • macOS 26.2 25C5031i darwin-arm64
        • Chrome (web)                  • chrome                    • web-javascript • Google Chrome 142.0.7444.135
        ! Error: Browsing on the local area network for Nexus. 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 [717ms]
        • All expected network resources are available.
    
    • No issues found!
    
    [!] Flutter (Channel master, 3.38.0-1.0.pre-474, on macOS 26.2 25C5031i darwin-arm64, locale en-US) [1,799ms]
        • Flutter version 3.38.0-1.0.pre-474 on channel master at /Users/deanli/dev/master
        ! Warning: `flutter` on your path resolves to /Users/deanli/dev/stable/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/deanli/dev/master. Consider adding /Users/deanli/dev/master/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/deanli/dev/stable/bin/dart, which is not inside your current Flutter SDK checkout at /Users/deanli/dev/master. Consider adding /Users/deanli/dev/master/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision e74c595450 (2 days ago), 2025-11-08 01:03:30 -0500
        • Engine revision e74c595450
        • Dart version 3.11.0 (build 3.11.0-113.0.dev)
        • DevTools version 2.52.0
        • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [1,243ms]
        • Android SDK at /Users/deanli/Library/Android/sdk
        • Emulator version 36.2.12.0 (build_id 14214601) (CL:N/A)
        • Platform android-36.1, build-tools 36.1.0
        • Java binary at: /Users/deanli/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 21.0.8+-14196175-b1038.72)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 26.2) [692ms]
        • Xcode at /Applications/Xcode-26.2.0-beta.app/Contents/Developer
        • Build 17C5013i
        • CocoaPods version 1.16.2
    
    [✓] Chrome - develop for the web [5ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Connected device (4 available) [6.1s]
        • Dean iPad (wireless) (mobile) • 00008103-000825C811E3401E • ios            • iOS 26.1 23B5059e
        • iPhone 16 Pro Max (mobile)    • 00008140-00194CC23A68801C • ios            • iOS 26.1 23B82
        • macOS (desktop)               • macos                     • darwin-arm64   • macOS 26.2 25C5031i darwin-arm64
        • Chrome (web)                  • chrome                    • web-javascript • Google Chrome 142.0.7444.135
        ! Error: Browsing on the local area network for Nexus. 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 [624ms]
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
  9. added
    a: text inputEntering text in a text field or keyboard related problems
    c: regressionIt was better in the past than it is now
    platform-webWeb applications specifically
    f: focusFocus traversal, gaining or losing focus
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Nov 10, 2025
  10. 13 remaining items

  11. self-assigned this
    on Jun 26, 2026
  12. added
    P1High-priority issues at the top of the work list
    and removed
    P2Important issues not at the top of the work list
    on Jun 26, 2026
  13. added a commit that references this issue on Jul 10, 2026
    6a01720
  14. github-actions commented on Jul 24, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  15. locked as resolved and limited conversation to collaborators on Jul 24, 2026
  16. flutter-zl commented on Aug 12, 2026

    @flutter-zl
    Contributor

    Reopen this because #188738 works on Safari not Chrome.
    The issue is reproducible with https://flutter-demo-45-after.web.app/ on chrome.

  17. flutter-zl commented on Aug 12, 2026

    @flutter-zl
    Contributor

    I redeployed https://flutter-demo-45-after.web.app with current master and it works on chrome and safari.

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

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: text inputEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowf: focusFocus traversal, gaining or losing focusfound in release: 3.35Found to occur in 3.35found in release: 3.38Found to occur in 3.38has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions