Skip to content

Commit ec9965b

Browse files
Reverts "Request focus if SemanticsAction.focus is sent to a focusable 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.
1 parent 63daac2 commit ec9965b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+70
-281
lines changed

dev/integration_tests/flutter_gallery/test/demo/material/chip_demo_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ void main() {
2020
isEnabled: true,
2121
isFocusable: true,
2222
hasTapAction: true,
23-
hasFocusAction: true,
2423
label: 'Update border shape',
2524
));
2625

@@ -30,7 +29,6 @@ void main() {
3029
isEnabled: true,
3130
isFocusable: true,
3231
hasTapAction: true,
33-
hasFocusAction: true,
3432
label: 'Reset chips',
3533
));
3634

packages/flutter/lib/src/widgets/focus_scope.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -671,14 +671,6 @@ class _FocusState extends State<Focus> {
671671
Widget child = widget.child;
672672
if (widget.includeSemantics) {
673673
child = Semantics(
674-
// Automatically request the focus for a focusable widget when it
675-
// receives an input focus action from the semantics. Nothing is needed
676-
// for losing the focus because if focus is lost, that means another
677-
// node will gain focus and take focus from this widget.
678-
onFocus:
679-
_couldRequestFocus
680-
? focusNode.requestFocus
681-
: null,
682674
focusable: _couldRequestFocus,
683675
focused: _hadPrimaryFocus,
684676
child: widget.child,

packages/flutter/test/cupertino/checkbox_test.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ void main() {
3434
hasEnabledState: true,
3535
isEnabled: true,
3636
hasTapAction: true,
37-
hasFocusAction: true,
3837
isFocusable: true,
3938
));
4039

@@ -55,7 +54,6 @@ void main() {
5554
isChecked: true,
5655
isEnabled: true,
5756
hasTapAction: true,
58-
hasFocusAction: true,
5957
isFocusable: true,
6058
));
6159

@@ -75,7 +73,6 @@ void main() {
7573
hasEnabledState: true,
7674
// isFocusable is delayed by 1 frame.
7775
isFocusable: true,
78-
hasFocusAction: true,
7976
));
8077

8178
await tester.pump();
@@ -181,7 +178,6 @@ void main() {
181178
hasEnabledState: true,
182179
isEnabled: true,
183180
hasTapAction: true,
184-
hasFocusAction: true,
185181
isFocusable: true,
186182
));
187183
handle.dispose();
@@ -251,7 +247,7 @@ void main() {
251247
SemanticsFlag.isFocusable,
252248
SemanticsFlag.isCheckStateMixed,
253249
],
254-
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
250+
actions: <SemanticsAction>[SemanticsAction.tap],
255251
), hasLength(1));
256252

257253
await tester.pumpWidget(
@@ -272,7 +268,7 @@ void main() {
272268
SemanticsFlag.isChecked,
273269
SemanticsFlag.isFocusable,
274270
],
275-
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
271+
actions: <SemanticsAction>[SemanticsAction.tap],
276272
), hasLength(1));
277273

278274
await tester.pumpWidget(
@@ -292,7 +288,7 @@ void main() {
292288
SemanticsFlag.isEnabled,
293289
SemanticsFlag.isFocusable,
294290
],
295-
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
291+
actions: <SemanticsAction>[SemanticsAction.tap],
296292
), hasLength(1));
297293

298294
semantics.dispose();

packages/flutter/test/cupertino/radio_test.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ void main() {
147147
],
148148
actions: <SemanticsAction>[
149149
SemanticsAction.tap,
150-
SemanticsAction.focus,
151150
],
152151
),
153152
);
@@ -172,7 +171,6 @@ void main() {
172171
hasEnabledState: true,
173172
isEnabled: true,
174173
hasTapAction: true,
175-
hasFocusAction: true,
176174
isFocusable: true,
177175
isInMutuallyExclusiveGroup: true,
178176
));
@@ -192,7 +190,6 @@ void main() {
192190
hasEnabledState: true,
193191
isEnabled: true,
194192
hasTapAction: true,
195-
hasFocusAction: true,
196193
isFocusable: true,
197194
isInMutuallyExclusiveGroup: true,
198195
isChecked: true,
@@ -213,7 +210,6 @@ void main() {
213210
hasEnabledState: true,
214211
isFocusable: true,
215212
isInMutuallyExclusiveGroup: true,
216-
hasFocusAction: true,
217213
));
218214

219215
await tester.pump();

packages/flutter/test/cupertino/route_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,7 @@ void main() {
19451945
await tester.pumpAndSettle();
19461946

19471947
expect(semantics, isNot(includesNodeWith(
1948-
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
1948+
actions: <SemanticsAction>[SemanticsAction.tap],
19491949
label: 'Dismiss',
19501950
)));
19511951
debugDefaultTargetPlatformOverride = null;

packages/flutter/test/cupertino/text_field_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2621,7 +2621,7 @@ void main() {
26212621
),
26222622
);
26232623

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

26262626
semantics.dispose();
26272627
});

packages/flutter/test/material/back_button_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ void main() {
215215
hasEnabledState: true,
216216
isEnabled: true,
217217
hasTapAction: true,
218-
hasFocusAction: true,
219218
isFocusable: true,
220219
));
221220
handle.dispose();
@@ -259,7 +258,6 @@ void main() {
259258
hasEnabledState: true,
260259
isEnabled: true,
261260
hasTapAction: true,
262-
hasFocusAction: true,
263261
isFocusable: true,
264262
));
265263
handle.dispose();

packages/flutter/test/material/bottom_navigation_bar_test.dart

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,7 +2111,6 @@ void main() {
21112111
isFocusable: true,
21122112
isSelected: true,
21132113
hasTapAction: true,
2114-
hasFocusAction: true,
21152114
),
21162115
);
21172116
expect(
@@ -2121,7 +2120,6 @@ void main() {
21212120
textDirection: TextDirection.ltr,
21222121
isFocusable: true,
21232122
hasTapAction: true,
2124-
hasFocusAction: true,
21252123
),
21262124
);
21272125
expect(
@@ -2131,7 +2129,6 @@ void main() {
21312129
textDirection: TextDirection.ltr,
21322130
isFocusable: true,
21332131
hasTapAction: true,
2134-
hasFocusAction: true,
21352132
),
21362133
);
21372134
});
@@ -2168,7 +2165,6 @@ void main() {
21682165
isFocusable: true,
21692166
isSelected: true,
21702167
hasTapAction: true,
2171-
hasFocusAction: true,
21722168
),
21732169
);
21742170
expect(
@@ -2178,7 +2174,6 @@ void main() {
21782174
textDirection: TextDirection.ltr,
21792175
isFocusable: true,
21802176
hasTapAction: true,
2181-
hasFocusAction: true,
21822177
),
21832178
);
21842179
expect(
@@ -2188,7 +2183,6 @@ void main() {
21882183
textDirection: TextDirection.ltr,
21892184
isFocusable: true,
21902185
hasTapAction: true,
2191-
hasFocusAction: true,
21922186
),
21932187
);
21942188
});
@@ -2521,7 +2515,6 @@ void main() {
25212515
isFocusable: true,
25222516
isSelected: true,
25232517
hasTapAction: true,
2524-
hasFocusAction: true,
25252518
),
25262519
);
25272520
expect(
@@ -2531,7 +2524,6 @@ void main() {
25312524
textDirection: TextDirection.ltr,
25322525
isFocusable: true,
25332526
hasTapAction: true,
2534-
hasFocusAction: true,
25352527
),
25362528
);
25372529
});
@@ -2566,7 +2558,6 @@ void main() {
25662558
isFocusable: true,
25672559
isSelected: true,
25682560
hasTapAction: true,
2569-
hasFocusAction: true,
25702561
),
25712562
);
25722563
expect(
@@ -2576,7 +2567,6 @@ void main() {
25762567
textDirection: TextDirection.ltr,
25772568
isFocusable: true,
25782569
hasTapAction: true,
2579-
hasFocusAction: true,
25802570
),
25812571
);
25822572
});
@@ -2757,13 +2747,13 @@ void main() {
27572747
SemanticsFlag.isSelected,
27582748
SemanticsFlag.isFocusable,
27592749
],
2760-
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
2750+
actions: <SemanticsAction>[SemanticsAction.tap],
27612751
label: 'A\nTab 1 of 2',
27622752
textDirection: TextDirection.ltr,
27632753
),
27642754
TestSemantics(
27652755
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
2766-
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
2756+
actions: <SemanticsAction>[SemanticsAction.tap],
27672757
label: 'B\nTab 2 of 2',
27682758
textDirection: TextDirection.ltr,
27692759
),

0 commit comments

Comments
 (0)