@@ -1776,7 +1776,7 @@ void _testIncrementables() {
1776
1776
1777
1777
pumpSemantics (isFocused: true );
1778
1778
expect (capturedActions, < CapturedAction > [
1779
- (0 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
1779
+ (0 , ui.SemanticsAction .focus , null ),
1780
1780
]);
1781
1781
capturedActions.clear ();
1782
1782
@@ -1787,10 +1787,12 @@ void _testIncrementables() {
1787
1787
isEmpty,
1788
1788
);
1789
1789
1790
+ // The web doesn't send didLoseAccessibilityFocus as on the web,
1791
+ // accessibility focus is not observable, only input focus is. As of this
1792
+ // writing, there is no SemanticsAction.unfocus action, so the test simply
1793
+ // asserts that no actions are being sent as a result of blur.
1790
1794
element.blur ();
1791
- expect (capturedActions, < CapturedAction > [
1792
- (0 , ui.SemanticsAction .didLoseAccessibilityFocus, null ),
1793
- ]);
1795
+ expect (capturedActions, isEmpty);
1794
1796
1795
1797
semantics ().semanticsEnabled = false ;
1796
1798
});
@@ -1821,15 +1823,14 @@ void _testTextField() {
1821
1823
1822
1824
1823
1825
final SemanticsObject node = owner ().debugSemanticsTree! [0 ]! ;
1826
+ final TextField textFieldRole = node.primaryRole! as TextField ;
1827
+ final DomHTMLInputElement inputElement = textFieldRole.activeEditableElement as DomHTMLInputElement ;
1824
1828
1825
1829
// TODO(yjbanov): this used to attempt to test that value="hello" but the
1826
1830
// test was a false positive. We should revise this test and
1827
1831
// make sure it tests the right things:
1828
1832
// https://github.com/flutter/flutter/issues/147200
1829
- expect (
1830
- (node.element as DomHTMLInputElement ).value,
1831
- isNull,
1832
- );
1833
+ expect (inputElement.value, '' );
1833
1834
1834
1835
expect (node.primaryRole? .role, PrimaryRole .textField);
1835
1836
expect (
@@ -1852,8 +1853,8 @@ void _testTextField() {
1852
1853
final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder ();
1853
1854
updateNode (
1854
1855
builder,
1855
- actions: 0 | ui.SemanticsAction .didGainAccessibilityFocus .index,
1856
- flags: 0 | ui.SemanticsFlag .isTextField.index,
1856
+ actions: 0 | ui.SemanticsAction .focus .index,
1857
+ flags: 0 | ui.SemanticsFlag .isTextField.index | ui. SemanticsFlag .isEnabled.index ,
1857
1858
value: 'hello' ,
1858
1859
transform: Matrix4 .identity ().toFloat64 (),
1859
1860
rect: const ui.Rect .fromLTRB (0 , 0 , 100 , 50 ),
@@ -1870,7 +1871,7 @@ void _testTextField() {
1870
1871
1871
1872
expect (owner ().semanticsHost.ownerDocument? .activeElement, textField);
1872
1873
expect (await logger.idLog.first, 0 );
1873
- expect (await logger.actionLog.first, ui.SemanticsAction .didGainAccessibilityFocus );
1874
+ expect (await logger.actionLog.first, ui.SemanticsAction .focus );
1874
1875
1875
1876
semantics ().semanticsEnabled = false ;
1876
1877
}, // TODO(yjbanov): https://github.com/flutter/flutter/issues/46638
@@ -2156,7 +2157,7 @@ void _testCheckables() {
2156
2157
2157
2158
pumpSemantics (isFocused: true );
2158
2159
expect (capturedActions, < CapturedAction > [
2159
- (0 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
2160
+ (0 , ui.SemanticsAction .focus , null ),
2160
2161
]);
2161
2162
capturedActions.clear ();
2162
2163
@@ -2166,15 +2167,12 @@ void _testCheckables() {
2166
2167
pumpSemantics (isFocused: false );
2167
2168
expect (capturedActions, isEmpty);
2168
2169
2169
- // If the element is blurred by the browser, then we do want to notify the
2170
- // framework. This is because screen reader can be focused on something
2171
- // other than what the framework is focused on, and notifying the framework
2172
- // about the loss of focus on a node is information that the framework did
2173
- // not have before.
2170
+ // The web doesn't send didLoseAccessibilityFocus as on the web,
2171
+ // accessibility focus is not observable, only input focus is. As of this
2172
+ // writing, there is no SemanticsAction.unfocus action, so the test simply
2173
+ // asserts that no actions are being sent as a result of blur.
2174
2174
element.blur ();
2175
- expect (capturedActions, < CapturedAction > [
2176
- (0 , ui.SemanticsAction .didLoseAccessibilityFocus, null ),
2177
- ]);
2175
+ expect (capturedActions, isEmpty);
2178
2176
2179
2177
semantics ().semanticsEnabled = false ;
2180
2178
});
@@ -2340,17 +2338,19 @@ void _testTappable() {
2340
2338
2341
2339
pumpSemantics (isFocused: true );
2342
2340
expect (capturedActions, < CapturedAction > [
2343
- (0 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
2341
+ (0 , ui.SemanticsAction .focus , null ),
2344
2342
]);
2345
2343
capturedActions.clear ();
2346
2344
2347
2345
pumpSemantics (isFocused: false );
2348
2346
expect (capturedActions, isEmpty);
2349
2347
2348
+ // The web doesn't send didLoseAccessibilityFocus as on the web,
2349
+ // accessibility focus is not observable, only input focus is. As of this
2350
+ // writing, there is no SemanticsAction.unfocus action, so the test simply
2351
+ // asserts that no actions are being sent as a result of blur.
2350
2352
element.blur ();
2351
- expect (capturedActions, < CapturedAction > [
2352
- (0 , ui.SemanticsAction .didLoseAccessibilityFocus, null ),
2353
- ]);
2353
+ expect (capturedActions, isEmpty);
2354
2354
2355
2355
semantics ().semanticsEnabled = false ;
2356
2356
});
@@ -3180,7 +3180,7 @@ void _testDialog() {
3180
3180
expect (
3181
3181
capturedActions,
3182
3182
< CapturedAction > [
3183
- (2 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
3183
+ (2 , ui.SemanticsAction .focus , null ),
3184
3184
],
3185
3185
);
3186
3186
@@ -3242,7 +3242,7 @@ void _testDialog() {
3242
3242
expect (
3243
3243
capturedActions,
3244
3244
< CapturedAction > [
3245
- (3 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
3245
+ (3 , ui.SemanticsAction .focus , null ),
3246
3246
],
3247
3247
);
3248
3248
@@ -3392,7 +3392,7 @@ void _testFocusable() {
3392
3392
pumpSemantics (); // triggers post-update callbacks
3393
3393
expect (domDocument.activeElement, element);
3394
3394
expect (capturedActions, < CapturedAction > [
3395
- (1 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
3395
+ (1 , ui.SemanticsAction .focus , null ),
3396
3396
]);
3397
3397
capturedActions.clear ();
3398
3398
@@ -3405,17 +3405,19 @@ void _testFocusable() {
3405
3405
// Browser blurs the element
3406
3406
element.blur ();
3407
3407
expect (domDocument.activeElement, isNot (element));
3408
- expect (capturedActions, < CapturedAction > [
3409
- (1 , ui.SemanticsAction .didLoseAccessibilityFocus, null ),
3410
- ]);
3408
+ // The web doesn't send didLoseAccessibilityFocus as on the web,
3409
+ // accessibility focus is not observable, only input focus is. As of this
3410
+ // writing, there is no SemanticsAction.unfocus action, so the test simply
3411
+ // asserts that no actions are being sent as a result of blur.
3412
+ expect (capturedActions, isEmpty);
3411
3413
capturedActions.clear ();
3412
3414
3413
3415
// Request focus again
3414
3416
manager.changeFocus (true );
3415
3417
pumpSemantics (); // triggers post-update callbacks
3416
3418
expect (domDocument.activeElement, element);
3417
3419
expect (capturedActions, < CapturedAction > [
3418
- (1 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
3420
+ (1 , ui.SemanticsAction .focus , null ),
3419
3421
]);
3420
3422
capturedActions.clear ();
3421
3423
0 commit comments