From eae0c6a3579defe9f8493144b71f994f5d0886d0 Mon Sep 17 00:00:00 2001 From: "auto-submit[bot]" <98614782+auto-submit[bot]@users.noreply.github.com> Date: Wed, 14 Feb 2024 22:17:18 +0000 Subject: [PATCH] Reverts "[a11y] Fix date picker cannot focus on the edit field (#143117)" (#143493) Reverts flutter/flutter#143117 Initiated by: dnfield Reason for reverting: made the tree red. Original PR Author: hangyujin Reviewed By: {QuncCccccc} This change reverts the following previous change: Original Description: fixes: https://github.com/flutter/flutter/issues/143116 fixes: https://github.com/flutter/flutter/issues/141992 https://b.corp.google.com/issues/322173632 --- .../src/material/calendar_date_picker.dart | 1 - .../flutter/lib/src/material/date_picker.dart | 108 ++++++++---------- .../input_date_picker_form_field.dart | 32 +++--- .../test/material/date_picker_test.dart | 23 +--- 4 files changed, 63 insertions(+), 101 deletions(-) diff --git a/packages/flutter/lib/src/material/calendar_date_picker.dart b/packages/flutter/lib/src/material/calendar_date_picker.dart index c7be8e5b25..e3cefd4775 100644 --- a/packages/flutter/lib/src/material/calendar_date_picker.dart +++ b/packages/flutter/lib/src/material/calendar_date_picker.dart @@ -394,7 +394,6 @@ class _DatePickerModeToggleButtonState extends State<_DatePickerModeToggleButton label: MaterialLocalizations.of(context).selectYearSemanticsLabel, excludeSemantics: true, button: true, - container: true, child: SizedBox( height: _subHeaderHeight, child: InkWell( diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart index 09b0c48bea..3056c7480c 100644 --- a/packages/flutter/lib/src/material/date_picker.dart +++ b/packages/flutter/lib/src/material/date_picker.dart @@ -867,76 +867,64 @@ class _DatePickerHeader extends StatelessWidget { switch (orientation) { case Orientation.portrait: - return Semantics( - container: true, - child: SizedBox( - height: _datePickerHeaderPortraitHeight, - child: Material( - color: backgroundColor, - child: Padding( - padding: const EdgeInsetsDirectional.only( - start: 24, - end: 12, - bottom: 12, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox(height: 16), - help, - const Flexible(child: SizedBox(height: 38)), - Row( - children: [ - Expanded(child: title), - if (entryModeButton != null) - Semantics( - container: true, - child: entryModeButton, - ), - ], - ), - ], - ), + return SizedBox( + height: _datePickerHeaderPortraitHeight, + child: Material( + color: backgroundColor, + child: Padding( + padding: const EdgeInsetsDirectional.only( + start: 24, + end: 12, + bottom: 12, + ), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 16), + help, + const Flexible(child: SizedBox(height: 38)), + Row( + children: [ + Expanded(child: title), + if (entryModeButton != null) + entryModeButton!, + ], + ), + ], ), ), ), ); case Orientation.landscape: - return Semantics( - container: true, - child:SizedBox( - width: _datePickerHeaderLandscapeWidth, - child: Material( - color: backgroundColor, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox(height: 16), - Padding( + return SizedBox( + width: _datePickerHeaderLandscapeWidth, + child: Material( + color: backgroundColor, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(height: 16), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: _headerPaddingLandscape, + ), + child: help, + ), + SizedBox(height: isShort ? 16 : 56), + Expanded( + child: Padding( padding: const EdgeInsets.symmetric( horizontal: _headerPaddingLandscape, ), - child: help, + child: title, ), - SizedBox(height: isShort ? 16 : 56), - Expanded( - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: _headerPaddingLandscape, - ), - child: title, - ), + ), + if (entryModeButton != null) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 4), + child: entryModeButton, ), - if (entryModeButton != null) - Padding( - padding: const EdgeInsets.symmetric(horizontal: 4), - child: Semantics( - container: true, - child: entryModeButton, - ), - ), - ], - ), + ], ), ), ); diff --git a/packages/flutter/lib/src/material/input_date_picker_form_field.dart b/packages/flutter/lib/src/material/input_date_picker_form_field.dart index 5a7d0653ff..6341360da6 100644 --- a/packages/flutter/lib/src/material/input_date_picker_form_field.dart +++ b/packages/flutter/lib/src/material/input_date_picker_form_field.dart @@ -256,25 +256,21 @@ class _InputDatePickerFormFieldState extends State { ?? theme.inputDecorationTheme.border ?? (useMaterial3 ? const OutlineInputBorder() : const UnderlineInputBorder()); - return Semantics( - container: true, - child: TextFormField( - decoration: InputDecoration( - hintText: widget.fieldHintText ?? localizations.dateHelpText, - labelText: widget.fieldLabelText ?? localizations.dateInputLabel, - ).applyDefaults( - inputTheme - .merge(datePickerTheme.inputDecorationTheme) - .copyWith(border: effectiveInputBorder), - ), - validator: _validateDate, - keyboardType: widget.keyboardType ?? TextInputType.datetime, - onSaved: _handleSaved, - onFieldSubmitted: _handleSubmitted, - autofocus: widget.autofocus, - controller: _controller, - focusNode: widget.focusNode, + return TextFormField( + decoration: InputDecoration( + hintText: widget.fieldHintText ?? localizations.dateHelpText, + labelText: widget.fieldLabelText ?? localizations.dateInputLabel, + ).applyDefaults(inputTheme + .merge(datePickerTheme.inputDecorationTheme) + .copyWith(border: effectiveInputBorder), ), + validator: _validateDate, + keyboardType: widget.keyboardType ?? TextInputType.datetime, + onSaved: _handleSaved, + onFieldSubmitted: _handleSubmitted, + autofocus: widget.autofocus, + controller: _controller, + focusNode: widget.focusNode, ); } } diff --git a/packages/flutter/test/material/date_picker_test.dart b/packages/flutter/test/material/date_picker_test.dart index 50d8797273..48d90f4270 100644 --- a/packages/flutter/test/material/date_picker_test.dart +++ b/packages/flutter/test/material/date_picker_test.dart @@ -13,7 +13,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import '../widgets/clipboard_utils.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); @@ -1578,13 +1577,6 @@ void main() { }); testWidgets('input mode', (WidgetTester tester) async { - // Fill the clipboard so that the Paste option is available in the text - // selection menu. - final MockClipboard mockClipboard = MockClipboard(); - tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, mockClipboard.handleMethodCall); - await Clipboard.setData(const ClipboardData(text: 'Clipboard data')); - addTearDown(() => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, null)); - final SemanticsHandle semantics = tester.ensureSemantics(); initialEntryMode = DatePickerEntryMode.input; @@ -1604,20 +1596,7 @@ void main() { isFocusable: true, )); - expect(tester.getSemantics(find.byType(EditableText)), matchesSemantics( - label: 'Enter Date', - isTextField: true, - isFocused: true, - value: '01/15/2016', - hasTapAction: true, - hasSetTextAction: true, - hasSetSelectionAction: true, - hasCopyAction: true, - hasCutAction: true, - hasPasteAction: true, - hasMoveCursorBackwardByCharacterAction: true, - hasMoveCursorBackwardByWordAction: true, - )); + // The semantics of the InputDatePickerFormField are tested in its tests. // Ok/Cancel buttons expect(tester.getSemantics(find.text('OK')), matchesSemantics(