fixed issue to where screen reader reads all buttons when opening datepicker (#152705)
removed container=true property from Semantics wrapper of datepicker dialog. This prevents the screen reader from reading every button in the datepicker dialog whenever a user opens it, reducing SR noise. Before: https://screencast.googleplex.com/cast/Njc0Mzc1MDA5MTk5NzE4NHw2NTU5ODI4YS0xNA After: https://screencast.googleplex.com/cast/NTYxMDUwOTIxMzYzMDQ2NHxjOWQ2M2YzNy1hYQ fixes b/345297872 NOTE: Please let me know if a test is needed for this, since it is only deleting code.
This commit is contained in:
@@ -435,7 +435,6 @@ class _DatePickerModeToggleButtonState extends State<_DatePickerModeToggleButton
|
||||
Flexible(
|
||||
child: Semantics(
|
||||
label: MaterialLocalizations.of(context).selectYearSemanticsLabel,
|
||||
excludeSemantics: true,
|
||||
button: true,
|
||||
container: true,
|
||||
child: SizedBox(
|
||||
@@ -788,6 +787,8 @@ class _MonthPickerState extends State<_MonthPicker> {
|
||||
final Color controlColor = Theme.of(context).colorScheme.onSurface.withOpacity(0.60);
|
||||
|
||||
return Semantics(
|
||||
container: true,
|
||||
explicitChildNodes: true,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
|
||||
@@ -855,8 +855,11 @@ void main() {
|
||||
|
||||
// Year mode drop down button.
|
||||
expect(tester.getSemantics(find.text('January 2016')), matchesSemantics(
|
||||
label: 'Select year',
|
||||
label: 'Select year\nJanuary 2016',
|
||||
isButton: true,
|
||||
hasTapAction: true,
|
||||
hasFocusAction: true,
|
||||
isFocusable: true,
|
||||
));
|
||||
|
||||
// Prev/Next month buttons.
|
||||
@@ -1104,8 +1107,11 @@ void main() {
|
||||
|
||||
// Year mode drop down button.
|
||||
expect(tester.getSemantics(find.text('January 2016')), matchesSemantics(
|
||||
label: 'Select year',
|
||||
label: 'Select year\nJanuary 2016',
|
||||
isButton: true,
|
||||
hasTapAction: true,
|
||||
hasFocusAction: true,
|
||||
isFocusable: true,
|
||||
));
|
||||
|
||||
// Year grid only shows 2010 - 2024.
|
||||
|
||||
@@ -11,6 +11,7 @@ import 'dart:ui';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import '../widgets/clipboard_utils.dart';
|
||||
@@ -1682,6 +1683,23 @@ void main() {
|
||||
});
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/pull/152705
|
||||
testWidgets('datepicker dialog semantics node not focusable', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Material(
|
||||
child: DatePickerDialog(
|
||||
initialDate: initialDate,
|
||||
firstDate: firstDate,
|
||||
lastDate: lastDate,
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
final SemanticsNode node = tester.semantics.find(find.byType(DatePickerDialog));
|
||||
final SemanticsData semanticsData = node.getSemanticsData();
|
||||
expect(semanticsData.hasFlag(SemanticsFlag.isFocusable), false);
|
||||
});
|
||||
});
|
||||
|
||||
group('Keyboard navigation', () {
|
||||
|
||||
Reference in New Issue
Block a user