Skip to content

[Web] Autocomplete loses keyboard focus after options appear when ensureSemantics() + MaterialApp.router are used #187561

Description

@SarukaUsagi

Steps to reproduce

  1. Create a Flutter web app with Go router and an Autocomplete widget
  2. Activate the flutter web's semantic tree (SemanticsBinding.instance.ensureSemantics();)
  3. Run the app on any browser
  4. Click the text field and try to type "aaa" with the keyboard

Expected results

The options overlay appears, the text field keeps focus. The user can continue typing to refine the search. Each new character updates the options list.

Actual results

When the options overlay is triggered, the text field loses keyboard focus. Any subsequent keystrokes are silently swallowed. The cursor disappears. The user must click the field again to regain focus, at which point the overlay appears but the focus is again stolen — making the field impossible to use.

Code sample

Dartpad : https://dartpad.dev/?id=8d8e1f6255e401934c794bbb85d89364

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

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  SemanticsBinding.instance.ensureSemantics();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  MyApp({super.key});

  final _router = GoRouter(
    routes: [GoRoute(path: '/', builder: (context, state) => const _Screen())],
  );

  @override
  Widget build(BuildContext context) =>
      MaterialApp.router(routerConfig: _router);
}

class _Screen extends StatelessWidget {
  const _Screen();

  static const List<String> _options = ['Apple', 'Banana', 'Cherry'];

  @override
  Widget build(BuildContext context) => Scaffold(
    body: Center(
      child: Autocomplete<String>(
        optionsBuilder: (TextEditingValue v) => v.text.isEmpty
            ? []
            : _options.where(
                (o) => o.toLowerCase().contains(v.text.toLowerCase()),
              ),
        onSelected: (s) => debugPrint('Selected: $s'),
      ),
    ),
  );
}

Tested flutter versions

We have tested the following versions :

Version Flutter Behavior
3.38.10 ✅ Works
3.41.3 ❌ Broken
3.44.0 ❌ Broken

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.44.0, on macOS 26.4.1 25E253 darwin-arm64, locale fr-FR) [441ms]
    • Flutter version 3.44.0 on channel stable at /Users/saruka/fvm/versions/3.44.0
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 559ffa3f75 (3 weeks ago), 2026-05-15 14:13:13 -0700
    • Engine revision 4c525dac5e
    • Dart version 3.12.0
    • DevTools version 2.57.0
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets,
      enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration

[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [1 297ms]
    • Android SDK at /Users/saruka/Library/Android/sdk
    • Emulator version 35.4.9.0 (build_id 13025442) (CL:N/A)
    • Platform android-36, build-tools 36.1.0
    • Java binary at: /Users/saruka/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.10+-117844308-b1163.108)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 26.5) [1 111ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 17F42
    • CocoaPods version 1.16.2

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

[✓] Connected device (2 available) [6,5s]
    • macOS (desktop) • macos  • darwin-arm64   • macOS 26.4.1 25E253 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 148.0.7778.216

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

• No issues found!

Activity

  1. added
    in triagePresently being triaged by the triage team
    platform-webWeb applications specifically
    a: text inputEntering text in a text field or keyboard related problems
    c: regressionIt was better in the past than it is now
    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    fyi-webFor the attention of Web platform team
    team-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)
    and removed
    in triagePresently being triaged by the triage team
    on Jun 4, 2026
  2. mbcorona commented on Jun 4, 2026

    @mbcorona
    Member

    Hello @SarukaUsagi , thanks for reporting. Reproduced on Web with Flutter 3.44.1. Routing to the accessibility team for investigation.

  3. added
    team-webOwned by Web platform team
    and removed
    team-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)
    on Jun 10, 2026
  4. hannah-hyj commented on Jun 10, 2026

    @hannah-hyj
    Member

    From triage: It seems like some dom element is stealing focus

  5. flutter-triage-bot commented on Jun 10, 2026

    @flutter-triage-bot

    The fyi-web label is redundant with the team-web label.
    The triaged-accessibility label is irrelevant if there is no team-accessibility label or fyi-accessibility label.

  6. assigned and unassigned on Sep 11, 2026
  7. added theissue type on Sep 11, 2026
  8. github-actions commented on Oct 1, 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.

  9. locked as resolved and limited conversation to collaborators on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: text inputEntering text in a text field or keyboard related problemsassigned for triageissue is assigned to a domain expert for further triagec: regressionIt was better in the past than it is nowcustomer: cabooseSee go/flutter-3p-customer-trackerhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyteam-webOwned by Web platform team

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions