Skip to content

Commit

Permalink
Reverts "[a11y] Add isEnabled semantics flag to text field (#143334)"…
Browse files Browse the repository at this point in the history
… (#143494)

Reverts flutter/flutter#143334

Initiated by: hangyujin

Reason for reverting: broke g3 tests

Original PR Author: hangyujin

Reviewed By: {LongCatIsLooong}

This change reverts the following previous change:
Original Description:
Add a semantics flag to   text field to fix flutter/flutter#143337 (in IOS the disabled text field is not read `dimmed`)

internal: b/322345393
  • Loading branch information
auto-submit[bot] authored Feb 14, 2024
1 parent eae0c6a commit 0fac13b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 94 deletions.
1 change: 0 additions & 1 deletion packages/flutter/lib/src/material/text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,6 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements
animation: controller, // changes the _currentLength
builder: (BuildContext context, Widget? child) {
return Semantics(
enabled: _isEnabled,
maxValueLength: semanticsMaxValueLength,
currentValueLength: _currentLength,
onTap: widget.readOnly ? null : () {
Expand Down
7 changes: 2 additions & 5 deletions packages/flutter/test/cupertino/text_field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,8 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 4,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
flags: <SemanticsFlag>[SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled,],
actions: <SemanticsAction>[SemanticsAction.tap,
SemanticsAction.didGainAccessibilityFocus,],
textDirection: TextDirection.ltr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ void main() {
expect(tester.getSemantics(find.byType(EditableText)), matchesSemantics(
label: 'Enter Date',
isTextField: true,
hasEnabledState: true,
isEnabled: true,
isFocused: true,
value: '01/15/2016',
hasTapAction: true,
Expand Down
4 changes: 0 additions & 4 deletions packages/flutter/test/material/search_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,6 @@ void main() {
id: 9,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocused,
SemanticsFlag.isHeader,
if (debugDefaultTargetPlatformOverride != TargetPlatform.iOS &&
Expand Down Expand Up @@ -820,8 +818,6 @@ void main() {
id: 11,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocused,
SemanticsFlag.isHeader,
if (debugDefaultTargetPlatformOverride != TargetPlatform.iOS &&
Expand Down
73 changes: 8 additions & 65 deletions packages/flutter/test/material/text_field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 4,
flags: <SemanticsFlag>[SemanticsFlag.isTextField, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled],
flags: <SemanticsFlag>[SemanticsFlag.isTextField],
actions: <SemanticsAction>[
SemanticsAction.tap,
SemanticsAction.didGainAccessibilityFocus,
Expand Down Expand Up @@ -1856,12 +1856,7 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 1,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocused,
],
flags: <SemanticsFlag>[SemanticsFlag.isTextField, SemanticsFlag.isFocused],
actions: <SemanticsAction>[
SemanticsAction.tap,
SemanticsAction.moveCursorBackwardByCharacter,
Expand Down Expand Up @@ -5194,8 +5189,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
),
TestSemantics.rootChild(
Expand Down Expand Up @@ -6537,7 +6530,7 @@ void main() {
),
);

expect(semantics, includesNodeWith(flags: <SemanticsFlag>[SemanticsFlag.isTextField, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled]));
expect(semantics, includesNodeWith(flags: <SemanticsFlag>[SemanticsFlag.isTextField]));

semantics.dispose();
});
Expand Down Expand Up @@ -6951,7 +6944,7 @@ void main() {
);

expect(semantics, includesNodeWith(
flags: <SemanticsFlag>[SemanticsFlag.isTextField, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled],
flags: <SemanticsFlag>[SemanticsFlag.isTextField],
maxValueLength: 10,
currentValueLength: 0,
));
Expand All @@ -6966,12 +6959,7 @@ void main() {
await tester.pump();

expect(semantics, includesNodeWith(
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocused,
],
flags: <SemanticsFlag>[SemanticsFlag.isTextField, SemanticsFlag.isFocused],
maxValueLength: 10,
currentValueLength: 3,
));
Expand All @@ -6997,12 +6985,7 @@ void main() {

expect(
semantics,
includesNodeWith(flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isReadOnly,
]),
includesNodeWith(flags: <SemanticsFlag>[SemanticsFlag.isTextField, SemanticsFlag.isReadOnly]),
);

semantics.dispose();
Expand Down Expand Up @@ -8028,8 +8011,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
),
],
Expand All @@ -8049,8 +8030,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
),
],
Expand All @@ -8076,8 +8055,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocused,
],
),
Expand Down Expand Up @@ -8106,8 +8083,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocused,
],
),
Expand Down Expand Up @@ -8135,8 +8110,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocused,
],
),
Expand All @@ -8162,8 +8135,6 @@ void main() {
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
value: 'Hello',
)
Expand All @@ -8179,8 +8150,6 @@ void main() {
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isObscured,
],
)
Expand All @@ -8196,8 +8165,6 @@ void main() {
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
value: 'Hello',
)
Expand Down Expand Up @@ -8240,8 +8207,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocused,
],
),
Expand Down Expand Up @@ -8277,8 +8242,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
),
],
Expand All @@ -8305,8 +8268,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocused,
],
),
Expand Down Expand Up @@ -8337,8 +8298,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocused,
],
),
Expand Down Expand Up @@ -8388,8 +8347,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocused,
],
),
Expand Down Expand Up @@ -8438,8 +8395,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocused,
],
),
Expand Down Expand Up @@ -8476,7 +8431,7 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: inputFieldId,
flags: <SemanticsFlag>[SemanticsFlag.isTextField, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled],
flags: <SemanticsFlag>[SemanticsFlag.isTextField],
actions: <SemanticsAction>[SemanticsAction.tap],
value: textInTextField,
textDirection: TextDirection.ltr,
Expand All @@ -8496,8 +8451,6 @@ void main() {
id: inputFieldId,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocused,
],
actions: <SemanticsAction>[
Expand Down Expand Up @@ -8551,7 +8504,7 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: inputFieldId,
flags: <SemanticsFlag>[SemanticsFlag.isTextField, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled],
flags: <SemanticsFlag>[SemanticsFlag.isTextField],
actions: <SemanticsAction>[SemanticsAction.tap],
value: textInTextField,
textDirection: TextDirection.ltr,
Expand All @@ -8571,8 +8524,6 @@ void main() {
id: inputFieldId,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocused,
],
actions: <SemanticsAction>[
Expand Down Expand Up @@ -8753,8 +8704,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
children: <TestSemantics>[
TestSemantics(
Expand Down Expand Up @@ -8790,8 +8739,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocused,
],
children: <TestSemantics>[
Expand Down Expand Up @@ -8849,8 +8796,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
children: <TestSemantics>[
TestSemantics(
Expand Down Expand Up @@ -8898,8 +8843,6 @@ void main() {
],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
],
children: <TestSemantics>[
TestSemantics(
Expand Down
14 changes: 2 additions & 12 deletions packages/flutter/test/material/time_picker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1343,12 +1343,7 @@ void main() {
label: 'Hour',
value: '07',
actions: <SemanticsAction>[SemanticsAction.tap],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isMultiline,
],
flags: <SemanticsFlag>[SemanticsFlag.isTextField, SemanticsFlag.isMultiline],
),
);
expect(
Expand All @@ -1357,12 +1352,7 @@ void main() {
label: 'Minute',
value: '00',
actions: <SemanticsAction>[SemanticsAction.tap],
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isMultiline,
],
flags: <SemanticsFlag>[SemanticsFlag.isTextField, SemanticsFlag.isMultiline],
),
);

Expand Down
9 changes: 4 additions & 5 deletions packages/flutter_test/test/controller_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,6 @@ void main() {
group('simulatedTraversal', () {
final List<Matcher> fullTraversalMatchers = <Matcher>[
containsSemantics(isHeader: true, label: 'Semantics Test'),
containsSemantics(label: 'Text Field'),
containsSemantics(isTextField: true),
containsSemantics(label: 'Off Switch'),
containsSemantics(hasToggledState: true),
Expand Down Expand Up @@ -914,7 +913,7 @@ void main() {
await tester.pumpWidget(const MaterialApp(home: _SemanticsTestWidget()));

// We're expecting the traversal to start where the slider is.
final List<Matcher> expectedMatchers = <Matcher>[...fullTraversalMatchers]..removeRange(0, 9);
final List<Matcher> expectedMatchers = <Matcher>[...fullTraversalMatchers]..removeRange(0, 8);

expect(
tester.semantics.simulatedAccessibilityTraversal(start: find.byType(Slider)),
Expand Down Expand Up @@ -977,7 +976,7 @@ void main() {
await tester.pumpWidget(const MaterialApp(home: _SemanticsTestWidget()));

// We're expecting the traversal to end where the slider is, inclusive.
final Iterable<Matcher> expectedMatchers = <Matcher>[...fullTraversalMatchers].getRange(0, 10);
final Iterable<Matcher> expectedMatchers = <Matcher>[...fullTraversalMatchers].getRange(0, 9);

expect(
tester.semantics.simulatedAccessibilityTraversal(end: find.byType(Slider)),
Expand Down Expand Up @@ -1038,7 +1037,7 @@ void main() {
await tester.pumpWidget(const MaterialApp(home: _SemanticsTestWidget()));

// We're expecting the traversal to start at the text field and end at the slider.
final Iterable<Matcher> expectedMatchers = <Matcher>[...fullTraversalMatchers].getRange(1, 10);
final Iterable<Matcher> expectedMatchers = <Matcher>[...fullTraversalMatchers].getRange(1, 9);

expect(
tester.semantics.simulatedAccessibilityTraversal(
Expand Down Expand Up @@ -1766,7 +1765,7 @@ class _SemanticsTestWidget extends StatelessWidget {
child: Column(
children: <Widget>[
const _SemanticsTestCard(
label: 'Text Field',
label: 'TextField',
widget: TextField(),
),
_SemanticsTestCard(
Expand Down

0 comments on commit 0fac13b

Please sign in to comment.