Skip to content

[Web] Unable to type in TextField when ensureSemantics is enabled for accessibility #129324

@jmandawg

Description

@jmandawg

Is there an existing issue for this?

Steps to reproduce

Run this sample code below you will not be able to type in the text field. Comment out the

SemanticsBinding.instance.ensureSemantics();

And you will be able to type in the text field.

Expected results

Be able to type in TextField

Actual results

Cannot type in TextField

Code sample

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

/// Flutter code sample for [EditableText.onChanged].

void main() {
  runApp(const OnChangedExampleApp());
  SemanticsBinding.instance.ensureSemantics();
  }

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


  static Route<dynamic> onGenerateRoutes() {
    return MaterialPageRoute(
          builder: (_) => const Center()
        );
  }

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: OnChangedExample(),
    );
  }
}

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

  @override
  State<OnChangedExample> createState() => _OnChangedExampleState();
}

class _OnChangedExampleState extends State<OnChangedExample> {
  final TextEditingController _controller = TextEditingController();

  final _navigator = GlobalKey<NavigatorState>();

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Column(
          mainAxisSize: MainAxisSize.max,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            TextField(
          onTap: (){
            print('Tap me');
          },
          autofocus: false,
        ),
            Expanded(
              child: Stack(
                children: [
                  Positioned.fill(
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Expanded(
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.stretch,
                            children: [
                              Expanded(
                                child: 
                                Navigator(
                                  key: _navigator,
                                  initialRoute: '/',
                                  onGenerateRoute: (settings) =>
                                      OnChangedExampleApp.onGenerateRoutes(),
                                )
                              ),
                            ],
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            )
          ],
        ),
      );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[!] Flutter (Channel unknown, 3.10.3, on macOS 13.4 22F66 darwin-arm64, locale en-US)
    ! Flutter version 3.10.3 on channel unknown at /Users/john/tools/flutter
      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/docs/get-started/install.
    ! Unknown upstream repository.
      Reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install.
    • Framework revision f92f44110e (3 weeks ago), 2023-06-01 18:17:33 -0500
    • Engine revision 2a3401c9bb
    • Dart version 3.0.3
    • DevTools version 2.23.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 31.0.0)
    • Android SDK at /Users/john/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0
    • ANDROID_HOME = /Users/john/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/john/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • CHROME_EXECUTABLE = /Applications/Chromium.app/Contents/MacOS/Chromium

[✓] Android Studio (version 2020.3)
    • Android Studio at /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 11.0.10+0-b96-7249189)

[✓] IntelliJ IDEA Community Edition (version 2021.2.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • 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

[✓] VS Code (version 1.79.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.66.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.4 22F66 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Chromium 115.0.5789.0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not 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 problemscustomer: castawaycustomer: crowdAffects or could affect many people, though not necessarily a specific customer.found in release: 3.10Found to occur in 3.10found in release: 3.12Found to occur in 3.12found in release: 3.41Found to occur in 3.41frameworkflutter/packages/flutter repository. See also f: labels.has 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 teamwaiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions