Skip to content

TextFields can't be interacted with when semantics are enabled #148285

Closed

Description

@tugorez

Steps to reproduce

  1. Go to https://fwa11y.web.app/#/text-field-password or any other app with a text field using an Android or iOS device
  2. Use a screen reader and enable semantics in the app
  3. Try to type text and you'll see the erratic behavior.

Expected results

Users should be able to easily type text into TextFields.

Actual results

It seems very complicated to type text into textfields when a screen reader is enabled.

Code sample

Another sample app
import 'package:flutter/material.dart';

void main() {
  runApp(App());
}

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Home(title: 'Flutter Focus'),
    );
  }
}

class Home extends StatefulWidget {
  const Home({super.key, required this.title});

  final String title;

  @override
  State<Home> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              for (int i = 0; i < 6; i++)
                if (i % 2 != 0)
                  const TextField(
                    decoration: InputDecoration(
                      border: OutlineInputBorder(),
                      labelText: 'Type Something',
                    ),
                  )
                else
                  TextButton(
                    onPressed: _incrementCounter,
                    child: const Text('Press me to increase count'),
                  ),
              Text('You have pushed the button this many times: $_counter'),
              const SizedBox(height: 100),
            ],
          ),
        ),
      ),
    );
  }
}

Flutter Doctor output

I'm able to reproduce this since version 3.19.0 on both Android and iOS using talback and voiceover respectively.

Activity

  1. darshankawar commented on May 14, 2024

    @darshankawar
    Member

    Thanks for the report. I ran the given code sample using latest stable (3.22.0) on Android as well as on iOS and below is my observation:

    1. Android (S10, running OS 12): With talkback ON and trying to type in the textfield, the talkback doesn't read the letters smoothly and stutters.
    2. iOS (iphone 6s, running OS 15.3.1) : With voiceover ON and trying to type in the textfield, the talkback reads the letters smoothly as expected and didn't observe any jitters while doing so.

    You mentioned that the behavior is same on Android and iOS. Can you provide short videos of both and sound enabled so that we can verify this further ?

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on May 14, 2024
  3. added
    a: text inputEntering text in a text field or keyboard related problems
    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)
    platform-webWeb applications specifically
    P0Critical issues such as a build break or regression
    team-webOwned by Web platform team
    triaged-webTriaged by Web platform team
    on May 14, 2024
  4. self-assigned this
    on May 14, 2024
  5. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    in triagePresently being triaged by the triage team
    on May 20, 2024
  6. yjbanov commented on May 21, 2024

    @yjbanov
    Contributor

    Starting to look into this one now.

  7. yjbanov commented on May 23, 2024

    @yjbanov
    Contributor

    The culprit seems to be this change: flutter-team-archive/engine#43279. That change replaced tap with didGainAccessibilityFocus. However, didGainAccessibilityFocus is not sufficient to start an editing session in the framework. The result is that the browser focuses on the <input> element, shows the virtual keyboard, and allows the user to change the value in the text field. All this happens while the framework is entirely unaware of any editing, as there's no TextInputConnection established between the framework and the engine.

    However, simply adding tap back to the "focus" handler will cause #128709 again. This situation ties back to #83809 where didLoseAccessibilityFocus does not result in the framework to remove the keyboard focus from the respective widget. As a result, the framework keeps sending hasFocus set to true on semantic nodes that should not have focus any more, which in return causes the browser to scroll to the semantic node that the user is not focusing on.

  8. changed the title [-]TextFields can't be interected with when semantics are enabled[/-] [+]TextFields can't be interacted with when semantics are enabled[/+] on May 28, 2024
  9. yjbanov commented on May 31, 2024

    @yjbanov
    Contributor

    We're very close to landing SemanticsAction.focus, so I'll attempt to fix this issue together with #83809 in flutter-team-archive/engine#53134.

  10. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jun 12, 2024
  11. github-actions commented on Jun 26, 2024

    @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.

  12. locked as resolved and limited conversation to collaborators on Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressiona: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: text inputEntering text in a text field or keyboard related problemsplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions