Skip to content

Commit

Permalink
Reverts "Request focus if SemanticsAction.focus is sent to a focusa…
Browse files Browse the repository at this point in the history
…ble widget (#142942)" (#149741)

Reverts: flutter/flutter#142942
Initiated by: zanderso
Reason for reverting: Seems to have affected iOS platform view focus: https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_ios%20native_platform_view_ui_tests_ios/10626/overview
Original PR Author: gspencergoog

Reviewed By: {yjbanov, goderbauer, chunhtai}

This change reverts the following previous change:
## Description

This causes the `Focus` widget to request focus on its focus node if the accessibility system (screen reader) focuses a widget via the `SemanticsAction.focus` action.

## Related Issues
 - flutter/flutter#83809

## Tests
 - Added a test to make sure that focus is requested when `SemanticsAction.focus` is sent by the engine.
  • Loading branch information
auto-submit[bot] authored Jun 5, 2024
1 parent 63daac2 commit ec9965b
Show file tree
Hide file tree
Showing 58 changed files with 70 additions and 281 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ void main() {
isEnabled: true,
isFocusable: true,
hasTapAction: true,
hasFocusAction: true,
label: 'Update border shape',
));

Expand All @@ -30,7 +29,6 @@ void main() {
isEnabled: true,
isFocusable: true,
hasTapAction: true,
hasFocusAction: true,
label: 'Reset chips',
));

Expand Down
8 changes: 0 additions & 8 deletions packages/flutter/lib/src/widgets/focus_scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -671,14 +671,6 @@ class _FocusState extends State<Focus> {
Widget child = widget.child;
if (widget.includeSemantics) {
child = Semantics(
// Automatically request the focus for a focusable widget when it
// receives an input focus action from the semantics. Nothing is needed
// for losing the focus because if focus is lost, that means another
// node will gain focus and take focus from this widget.
onFocus:
_couldRequestFocus
? focusNode.requestFocus
: null,
focusable: _couldRequestFocus,
focused: _hadPrimaryFocus,
child: widget.child,
Expand Down
10 changes: 3 additions & 7 deletions packages/flutter/test/cupertino/checkbox_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ void main() {
hasEnabledState: true,
isEnabled: true,
hasTapAction: true,
hasFocusAction: true,
isFocusable: true,
));

Expand All @@ -55,7 +54,6 @@ void main() {
isChecked: true,
isEnabled: true,
hasTapAction: true,
hasFocusAction: true,
isFocusable: true,
));

Expand All @@ -75,7 +73,6 @@ void main() {
hasEnabledState: true,
// isFocusable is delayed by 1 frame.
isFocusable: true,
hasFocusAction: true,
));

await tester.pump();
Expand Down Expand Up @@ -181,7 +178,6 @@ void main() {
hasEnabledState: true,
isEnabled: true,
hasTapAction: true,
hasFocusAction: true,
isFocusable: true,
));
handle.dispose();
Expand Down Expand Up @@ -251,7 +247,7 @@ void main() {
SemanticsFlag.isFocusable,
SemanticsFlag.isCheckStateMixed,
],
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
actions: <SemanticsAction>[SemanticsAction.tap],
), hasLength(1));

await tester.pumpWidget(
Expand All @@ -272,7 +268,7 @@ void main() {
SemanticsFlag.isChecked,
SemanticsFlag.isFocusable,
],
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
actions: <SemanticsAction>[SemanticsAction.tap],
), hasLength(1));

await tester.pumpWidget(
Expand All @@ -292,7 +288,7 @@ void main() {
SemanticsFlag.isEnabled,
SemanticsFlag.isFocusable,
],
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
actions: <SemanticsAction>[SemanticsAction.tap],
), hasLength(1));

semantics.dispose();
Expand Down
4 changes: 0 additions & 4 deletions packages/flutter/test/cupertino/radio_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ void main() {
],
actions: <SemanticsAction>[
SemanticsAction.tap,
SemanticsAction.focus,
],
),
);
Expand All @@ -172,7 +171,6 @@ void main() {
hasEnabledState: true,
isEnabled: true,
hasTapAction: true,
hasFocusAction: true,
isFocusable: true,
isInMutuallyExclusiveGroup: true,
));
Expand All @@ -192,7 +190,6 @@ void main() {
hasEnabledState: true,
isEnabled: true,
hasTapAction: true,
hasFocusAction: true,
isFocusable: true,
isInMutuallyExclusiveGroup: true,
isChecked: true,
Expand All @@ -213,7 +210,6 @@ void main() {
hasEnabledState: true,
isFocusable: true,
isInMutuallyExclusiveGroup: true,
hasFocusAction: true,
));

await tester.pump();
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/cupertino/route_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1945,7 +1945,7 @@ void main() {
await tester.pumpAndSettle();

expect(semantics, isNot(includesNodeWith(
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'Dismiss',
)));
debugDefaultTargetPlatformOverride = null;
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/cupertino/text_field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2621,7 +2621,7 @@ void main() {
),
);

expect(semantics, isNot(includesNodeWith(actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus])));
expect(semantics, isNot(includesNodeWith(actions: <SemanticsAction>[SemanticsAction.tap])));

semantics.dispose();
});
Expand Down
2 changes: 0 additions & 2 deletions packages/flutter/test/material/back_button_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ void main() {
hasEnabledState: true,
isEnabled: true,
hasTapAction: true,
hasFocusAction: true,
isFocusable: true,
));
handle.dispose();
Expand Down Expand Up @@ -259,7 +258,6 @@ void main() {
hasEnabledState: true,
isEnabled: true,
hasTapAction: true,
hasFocusAction: true,
isFocusable: true,
));
handle.dispose();
Expand Down
14 changes: 2 additions & 12 deletions packages/flutter/test/material/bottom_navigation_bar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2111,7 +2111,6 @@ void main() {
isFocusable: true,
isSelected: true,
hasTapAction: true,
hasFocusAction: true,
),
);
expect(
Expand All @@ -2121,7 +2120,6 @@ void main() {
textDirection: TextDirection.ltr,
isFocusable: true,
hasTapAction: true,
hasFocusAction: true,
),
);
expect(
Expand All @@ -2131,7 +2129,6 @@ void main() {
textDirection: TextDirection.ltr,
isFocusable: true,
hasTapAction: true,
hasFocusAction: true,
),
);
});
Expand Down Expand Up @@ -2168,7 +2165,6 @@ void main() {
isFocusable: true,
isSelected: true,
hasTapAction: true,
hasFocusAction: true,
),
);
expect(
Expand All @@ -2178,7 +2174,6 @@ void main() {
textDirection: TextDirection.ltr,
isFocusable: true,
hasTapAction: true,
hasFocusAction: true,
),
);
expect(
Expand All @@ -2188,7 +2183,6 @@ void main() {
textDirection: TextDirection.ltr,
isFocusable: true,
hasTapAction: true,
hasFocusAction: true,
),
);
});
Expand Down Expand Up @@ -2521,7 +2515,6 @@ void main() {
isFocusable: true,
isSelected: true,
hasTapAction: true,
hasFocusAction: true,
),
);
expect(
Expand All @@ -2531,7 +2524,6 @@ void main() {
textDirection: TextDirection.ltr,
isFocusable: true,
hasTapAction: true,
hasFocusAction: true,
),
);
});
Expand Down Expand Up @@ -2566,7 +2558,6 @@ void main() {
isFocusable: true,
isSelected: true,
hasTapAction: true,
hasFocusAction: true,
),
);
expect(
Expand All @@ -2576,7 +2567,6 @@ void main() {
textDirection: TextDirection.ltr,
isFocusable: true,
hasTapAction: true,
hasFocusAction: true,
),
);
});
Expand Down Expand Up @@ -2757,13 +2747,13 @@ void main() {
SemanticsFlag.isSelected,
SemanticsFlag.isFocusable,
],
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'A\nTab 1 of 2',
textDirection: TextDirection.ltr,
),
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'B\nTab 2 of 2',
textDirection: TextDirection.ltr,
),
Expand Down
Loading

0 comments on commit ec9965b

Please sign in to comment.