Repository navigation
Description
Package and environment
- Package:
go_router18.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
- Run
flutter create --platforms=web bugand addgo_router: 18.1.1topubspec.yaml. - Replace
lib/main.dartwith the code below. - 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_router18.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 acceptedtex. - A
go_routerregression test fails before that change with an extra semantics parent and passes after it. The existing shell chrome tests also pass.
Activity
saurabh-mirajkar commentedon Oct 21, 2026
@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 forteam-accessibilityto investigate further.[go_router] Keep web autocomplete focused in shell routes (flutter#13348
github-actions commentedon Nov 5, 2026
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 -vand a minimal reproduction of the issue.