Repository navigation
[a11y] VoiceOver does not announce form validation errors #99715
Copy link
Copy link
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)Accessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemscustomer: troyfound in release: 2.10Found to occur in 2.10Found to occur in 2.10found in release: 2.11Found to occur in 2.11Found to occur in 2.11frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesplatform-webWeb applications specificallyWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
If a form field fails validation, the error message is visually displayed but is not announced by VoiceOver.
Steps to Reproduce
- Turn on VoiceOver.
- Execute
flutter run -d chromeon the code sample. - Tap "Submit" without entering a username.
Expected results:
The validation error message ("Please enter your username") is announced by VoiceOver.
Actual results:
The validation error message is displayed but is not read.
Workaround:
If the helperText is set to a space, the validation error message will be announced. 🤷🏾
TextFormField(
decoration: const InputDecoration(
helperText: ' ', // Must be set to a space to announce validation errors.
labelText: 'Username',
),
validator: (String? value) {
if (value == null || value.isEmpty) {
return 'Please enter your username';
}
return null;
},
),Code sample
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
// Auto-enable accessibility for our Blind and Low Vision customers (see
// https://docs.flutter.dev/development/accessibility-and-localization/accessibility#screen-readers).
RendererBinding.instance!.setSemanticsEnabled(true);
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
const appTitle = 'Form Validation Demo';
return MaterialApp(
title: appTitle,
home: Scaffold(
appBar: AppBar(
title: const Text(appTitle),
),
body: const MyCustomForm(),
),
);
}
}
class MyCustomForm extends StatefulWidget {
const MyCustomForm({Key? key}) : super(key: key);
@override
State<MyCustomForm> createState() => _MyCustomFormState();
}
class _MyCustomFormState extends State<MyCustomForm> {
final _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return Form(
key: _formKey,
child: Column(
children: <Widget>[
TextFormField(
decoration: const InputDecoration(
labelText: 'Username',
),
validator: (String? value) {
if (value == null || value.isEmpty) {
return 'Please enter your username';
}
return null;
},
),
TextButton(
onPressed: () {
if (_formKey.currentState!.validate()) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Submitting...')),
);
}
},
child: const Text('Submit'),
),
],
),
);
}
}Logs
[✓] Flutter (Channel stable, 2.10.3, on macOS 11.6.2 20G314 darwin-x64, locale en-US)
• Flutter version 2.10.3 at /Users/vsomayaji/Dev/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7e9793dee1 (5 days ago), 2022-03-02 11:23:12 -0600
• Engine revision bd539267b4
• Dart version 2.16.1
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/vsomayaji/Library/Android/sdk
• Platform android-31, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] 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-7281165)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.1.2)
• IntelliJ at /Applications/IntelliJ IDEA.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
[✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.109
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
FormValidationDemo.mov
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)Accessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemscustomer: troyfound in release: 2.10Found to occur in 2.10Found to occur in 2.10found in release: 2.11Found to occur in 2.11Found to occur in 2.11frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesplatform-webWeb applications specificallyWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Activity
vsomayaji commentedon Mar 8, 2022
In case anyone tries the workaround mentioned in the issue, it should (🤞🏾) solve for the initial announcement of the
errorText; however, on subsequent validations, if theerrorTextstays the same, it won't be announced. See the attached video for an example.To workaround that issue, we are toggling appending a space to the
errorText(full code sample below). If anyone's got a better solution, let us know!Code sample
FormValidationDemo.mov
darshankawar commentedon Mar 9, 2022
Thanks for the detailed report @vsomayaji. I believe this isn't specific to web, as on mobile as well the same behavior occurs.
stable, master flutter doctor -v
Labeling it as a framework issue.
Similar / related : #91472
fortinjoffrey commentedon Jul 1, 2022
Any updates on this issue ?
PoojaPatilCybage commentedon Feb 3, 2023
Any update on this?
bourdakos1 commentedon Feb 15, 2023
I'm seeing the same issue. However, when building for macOS or Windows the workaround doesn't work and "Submitting..." isn't announced on success.
16 remaining items
hannah-hyj commentedon Mar 21, 2023
Synced with ChunHeng offline, it seems SemanticsService.announce is not implemented in macOS. We need to implement it using NSAccessibilityAnnouncementRequestedNotification.
loic-sharma commentedon Mar 30, 2023
@Hangyujin I verified your fix works on Windows, both NVDA and Narrator announced an alert for the example in the original post.
cbracken commentedon Mar 30, 2023
@yjbanov if support for making semantics announcements is already supported in the web embedding, it may be worth re-testing to see if this now works for web.
We'll want to do the same for the Linux embedding.
cbracken commentedon Mar 30, 2023
Adjusted priority as this is fixed for the platforms that were a ship-blocker.
yjbanov commentedon Apr 10, 2023
Can we close this now?
hannah-hyj commentedon Apr 10, 2023
@yjbanov If you can help confirm semantics announcement is supported for web, we can close this now.
yjbanov commentedon Apr 10, 2023
Confirming that semantics announcement works on the web. However, I don't know if it working alone is sufficient to fix this issue. Is there a sample app we can test this with?
hannah-hyj commentedon Apr 10, 2023
@yjbanov I just use the "code sample" in this issue description to test.
yjbanov commentedon Apr 11, 2023
The provided sample works in Chrome, Safari, and Firefox. I'm ok with considering this as fixed on the web.
github-actions commentedon Apr 25, 2023
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.