Skip to content

[go_router][web] Autocomplete field loses focus in ShellRoute with semantics enabled #194873

Closed
flutter/packages
#13348

Description

@agpdl

Package and environment

  • Package: go_router 18.1.1
  • Platform: Flutter web in Chrome on macOS
  • Flutter 3.47.5, Dart 3.13.4
  • Packages upgraded: yes. The browser repro below uses the published 18.1.1 release.

Steps to reproduce

  1. Run flutter create --platforms=web bug and add go_router: 18.1.1 to pubspec.yaml.
  2. Replace lib/main.dart with the code below.
  3. Run the app in Chrome, click the State field, and type tex.

Expected results

The field keeps browser focus, contains tex, and shows the matching Texas option.

Actual results

Opening the autocomplete options detaches the focused semantic <input> from the DOM. The field blurs before the first character sticks. In a headless Chrome run, typing t, e, and x left the value empty and document.activeElement === input was false after each key.

This started with go_router 18.0.2. Version 18.0.1 works; 18.1.1 still reproduces it. The shell navigator's Semantics(container: true) wrapper was added in flutter/packages#12353 to preserve shell chrome semantics. Adding explicitChildNodes: true to that wrapper kept the focused input's semantics parent stable in a widget test, fixed the browser repro, and preserved the existing shell chrome semantics tests.

This differs from #187561, which addressed the missing WidgetsApp.router focus scope.

Code sample

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

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  SemanticsBinding.instance.ensureSemantics();
  runApp(const FocusRepro());
}

class FocusRepro extends StatefulWidget {
  const FocusRepro({super.key});

  @override
  State<FocusRepro> createState() => _FocusReproState();
}

class _FocusReproState extends State<FocusRepro> {
  late final GoRouter router = GoRouter(
    routes: [
      ShellRoute(
        builder: (context, state, child) => Scaffold(
          body: Row(
            children: [
              Semantics(
                container: true,
                label: 'Shell navigation',
                child: const SizedBox(width: 80, child: Text('Nav')),
              ),
              Expanded(child: child),
            ],
          ),
        ),
        routes: [
          ShellRoute(
            builder: (context, state, child) => child,
            routes: [
              GoRoute(path: '/', builder: (context, state) => const StateField()),
            ],
          ),
        ],
      ),
    ],
  );

  @override
  void dispose() {
    router.dispose();
    super.dispose();
  }

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

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

  @override
  Widget build(BuildContext context) => Center(
    child: SizedBox(
      width: 300,
      child: Autocomplete<String>(
        optionsBuilder: (value) => ['Texas', 'Tennessee', 'New York']
            .where((option) => option.toLowerCase().contains(value.text.toLowerCase())),
        fieldViewBuilder: (context, controller, focusNode, onFieldSubmitted) => TextField(
          key: const ValueKey('state-field'),
          controller: controller,
          focusNode: focusNode,
          decoration: const InputDecoration(labelText: 'State'),
        ),
      ),
    ),
  );
}

Verification

  • Published go_router 18.1.1, Flutter 3.47.5, release web build in Chrome: the input blurred and accepted no typed characters.
  • With Semantics(container: true, explicitChildNodes: true) on the shell navigator: the same browser repro retained focus and accepted tex.
  • A go_router regression test fails before that change with an extra semantics parent and passes after it. The existing shell chrome tests also pass.

Activity

  1. saurabh-mirajkar commented on Oct 21, 2026

    @saurabh-mirajkar
    Contributor

    @agpdl Thanks for the report.I am able to reproduce this on latest stable using the provided code sample whereas this works on go_router: 18.0.1. Labelling for team-accessibility to investigate further.

  2. added
    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)
    platform-webWeb applications specifically
    packageflutter/packages repository. See also p: labels.
    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 Oct 21, 2026
  3. self-assigned this
    on Oct 21, 2026
  4. added
    P1High-priority issues at the top of the work list
    triaged-webTriaged by Web platform team
    on Oct 21, 2026
  5. added a commit that references this issue on Oct 22, 2026
    e872aea
  6. github-actions commented on Nov 5, 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.

  7. locked as resolved and limited conversation to collaborators on Nov 5, 2026
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: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: text inputEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.platform-webWeb applications specificallyteam-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions