@@ -1776,7 +1776,7 @@ void _testIncrementables() {
17761776
17771777 pumpSemantics (isFocused: true );
17781778 expect (capturedActions, < CapturedAction > [
1779- (0 , ui.SemanticsAction .focus , null ),
1779+ (0 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
17801780 ]);
17811781 capturedActions.clear ();
17821782
@@ -1787,12 +1787,10 @@ void _testIncrementables() {
17871787 isEmpty,
17881788 );
17891789
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.
17941790 element.blur ();
1795- expect (capturedActions, isEmpty);
1791+ expect (capturedActions, < CapturedAction > [
1792+ (0 , ui.SemanticsAction .didLoseAccessibilityFocus, null ),
1793+ ]);
17961794
17971795 semantics ().semanticsEnabled = false ;
17981796 });
@@ -1823,14 +1821,15 @@ void _testTextField() {
18231821
18241822
18251823 final SemanticsObject node = owner ().debugSemanticsTree! [0 ]! ;
1826- final TextField textFieldRole = node.primaryRole! as TextField ;
1827- final DomHTMLInputElement inputElement = textFieldRole.activeEditableElement as DomHTMLInputElement ;
18281824
18291825 // TODO(yjbanov): this used to attempt to test that value="hello" but the
18301826 // test was a false positive. We should revise this test and
18311827 // make sure it tests the right things:
18321828 // https://github.com/flutter/flutter/issues/147200
1833- expect (inputElement.value, '' );
1829+ expect (
1830+ (node.element as DomHTMLInputElement ).value,
1831+ isNull,
1832+ );
18341833
18351834 expect (node.primaryRole? .role, PrimaryRole .textField);
18361835 expect (
@@ -1853,8 +1852,8 @@ void _testTextField() {
18531852 final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder ();
18541853 updateNode (
18551854 builder,
1856- actions: 0 | ui.SemanticsAction .focus .index,
1857- flags: 0 | ui.SemanticsFlag .isTextField.index | ui. SemanticsFlag .isEnabled.index ,
1855+ actions: 0 | ui.SemanticsAction .didGainAccessibilityFocus .index,
1856+ flags: 0 | ui.SemanticsFlag .isTextField.index,
18581857 value: 'hello' ,
18591858 transform: Matrix4 .identity ().toFloat64 (),
18601859 rect: const ui.Rect .fromLTRB (0 , 0 , 100 , 50 ),
@@ -1871,7 +1870,7 @@ void _testTextField() {
18711870
18721871 expect (owner ().semanticsHost.ownerDocument? .activeElement, textField);
18731872 expect (await logger.idLog.first, 0 );
1874- expect (await logger.actionLog.first, ui.SemanticsAction .focus );
1873+ expect (await logger.actionLog.first, ui.SemanticsAction .didGainAccessibilityFocus );
18751874
18761875 semantics ().semanticsEnabled = false ;
18771876 }, // TODO(yjbanov): https://github.com/flutter/flutter/issues/46638
@@ -2157,7 +2156,7 @@ void _testCheckables() {
21572156
21582157 pumpSemantics (isFocused: true );
21592158 expect (capturedActions, < CapturedAction > [
2160- (0 , ui.SemanticsAction .focus , null ),
2159+ (0 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
21612160 ]);
21622161 capturedActions.clear ();
21632162
@@ -2167,12 +2166,15 @@ void _testCheckables() {
21672166 pumpSemantics (isFocused: false );
21682167 expect (capturedActions, isEmpty);
21692168
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.
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.
21742174 element.blur ();
2175- expect (capturedActions, isEmpty);
2175+ expect (capturedActions, < CapturedAction > [
2176+ (0 , ui.SemanticsAction .didLoseAccessibilityFocus, null ),
2177+ ]);
21762178
21772179 semantics ().semanticsEnabled = false ;
21782180 });
@@ -2338,19 +2340,17 @@ void _testTappable() {
23382340
23392341 pumpSemantics (isFocused: true );
23402342 expect (capturedActions, < CapturedAction > [
2341- (0 , ui.SemanticsAction .focus , null ),
2343+ (0 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
23422344 ]);
23432345 capturedActions.clear ();
23442346
23452347 pumpSemantics (isFocused: false );
23462348 expect (capturedActions, isEmpty);
23472349
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.
23522350 element.blur ();
2353- expect (capturedActions, isEmpty);
2351+ expect (capturedActions, < CapturedAction > [
2352+ (0 , ui.SemanticsAction .didLoseAccessibilityFocus, null ),
2353+ ]);
23542354
23552355 semantics ().semanticsEnabled = false ;
23562356 });
@@ -3180,7 +3180,7 @@ void _testDialog() {
31803180 expect (
31813181 capturedActions,
31823182 < CapturedAction > [
3183- (2 , ui.SemanticsAction .focus , null ),
3183+ (2 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
31843184 ],
31853185 );
31863186
@@ -3242,7 +3242,7 @@ void _testDialog() {
32423242 expect (
32433243 capturedActions,
32443244 < CapturedAction > [
3245- (3 , ui.SemanticsAction .focus , null ),
3245+ (3 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
32463246 ],
32473247 );
32483248
@@ -3392,7 +3392,7 @@ void _testFocusable() {
33923392 pumpSemantics (); // triggers post-update callbacks
33933393 expect (domDocument.activeElement, element);
33943394 expect (capturedActions, < CapturedAction > [
3395- (1 , ui.SemanticsAction .focus , null ),
3395+ (1 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
33963396 ]);
33973397 capturedActions.clear ();
33983398
@@ -3405,19 +3405,17 @@ void _testFocusable() {
34053405 // Browser blurs the element
34063406 element.blur ();
34073407 expect (domDocument.activeElement, isNot (element));
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);
3408+ expect (capturedActions, < CapturedAction > [
3409+ (1 , ui.SemanticsAction .didLoseAccessibilityFocus, null ),
3410+ ]);
34133411 capturedActions.clear ();
34143412
34153413 // Request focus again
34163414 manager.changeFocus (true );
34173415 pumpSemantics (); // triggers post-update callbacks
34183416 expect (domDocument.activeElement, element);
34193417 expect (capturedActions, < CapturedAction > [
3420- (1 , ui.SemanticsAction .focus , null ),
3418+ (1 , ui.SemanticsAction .didGainAccessibilityFocus , null ),
34213419 ]);
34223420 capturedActions.clear ();
34233421
0 commit comments