Repository navigation
Description
Steps to reproduce
- Run the sample below with
flutter run -d chrome. - The field has the focus. Type a few characters.
- Click "Click this text".
- Type again.
The sample calls SemanticsBinding.instance.ensureSemantics(). Without that line, everything works. An app without it gets the same bug as soon as a user activates Flutter web's hidden "Enable accessibility" button.
Expected results
The characters typed after the click appear in the field. The text is in the field's tap region, so the field keeps the focus, as it does for a formatting toolbar.
Actual results
The field keeps the focus in the framework, and its caret keeps blinking, but nothing typed after the click appears. document.activeElement is the flutter-view element.
Clicking a part of the tap region that has no semantics node, such as empty space in a Container, does not break typing.
What I think happens: the mouse press on the text's semantics element moves the browser focus to its nearest focusable ancestor, the flutter-view element. With semantics enabled, the field types into the <input> of its SemanticTextField, whose blur listener calls SemanticsTextEditingStrategy.deactivate. Nothing activates it again, because the framework focus never changed. With semantics disabled, the default editing strategy handles the same blur by focusing its <input> again.
Workaround: keep the browser from moving the focus.
// Called once at startup, on the web only.
web.EventStreamProviders.mouseDownEvent
.forTarget(web.document, useCapture: true)
.listen((event) {
final active = web.document.activeElement;
if (active?.getAttribute('data-semantics-role') != 'text-field') return;
final target = event.target as web.Element;
if (target.getAttribute('data-semantics-role') == 'text-field') return;
if (target.closest('flt-semantics') != null) event.preventDefault();
});Code sample
Code sample
import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
SemanticsBinding.instance.ensureSemantics();
runApp(
const MaterialApp(
home: Scaffold(
body: Padding(
padding: EdgeInsets.all(24),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Part of the text field's tap region, like a formatting toolbar.
TextFieldTapRegion(child: Text('Click this text')),
TextField(autofocus: true),
],
),
),
),
),
);
}Screenshots or Video
No response
Logs
No response
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.47.7, on macOS 27.0.1 26A434 darwin-arm64, locale en-US)
• Flutter version 3.47.7 on channel stable at /Users/gringo/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision abaf9c5237 (2 weeks ago), 2026-10-08 09:51:21 -0700
• Engine revision deb287481e
• Dart version 3.13.5
• DevTools version 2.60.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 27.0.1 26A434 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 155.0.8059.85
Activity
mbcorona commentedon Oct 26, 2026
Hi @nogringo, thanks for the report.
Same area as #195289 and #195290.
Routing to team-accessibility.
flutter-zl commentedon Oct 28, 2026