File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -312,17 +312,18 @@ void MoveCard(bool shouldMoveLeft, int count)
312
312
AssistiveSupport . activeHierarchy . MoveNode ( element . node , element . node . parent ,
313
313
element . transform . GetSiblingIndex ( ) ) ;
314
314
315
- // Only refresh the frames for now to leave the announcement request to be handled.
316
- StartCoroutine ( RefreshNodeFrames ( ) ) ;
317
-
318
- AssistiveSupport . notificationDispatcher . SendLayoutChanged ( element . node ) ;
315
+ // After the move, the screen reader will refocus on the other card, but with a little delay. Move the
316
+ // focus to the selected card, but wait a bit to let the first focus change complete. Otherwise, the
317
+ // screen reader will focus on the selected card first, then still on the other card, triggering an
318
+ // infinite swap of the two cards.
319
+ StartCoroutine ( DelaySendLayoutChanged ( ) ) ;
319
320
return ;
320
321
321
- IEnumerator RefreshNodeFrames ( )
322
+ IEnumerator DelaySendLayoutChanged ( )
322
323
{
323
324
yield return new WaitForEndOfFrame ( ) ;
324
325
325
- AssistiveSupport . activeHierarchy ? . RefreshNodeFrames ( ) ;
326
+ AssistiveSupport . notificationDispatcher . SendLayoutChanged ( element . node ) ;
326
327
}
327
328
}
328
329
}
Original file line number Diff line number Diff line change @@ -734,6 +734,10 @@ void MoveCard(bool shouldMoveLeft, int count = 1)
734
734
m_LetterCardContainer . selectedCard . MoveLeft ( count ) :
735
735
m_LetterCardContainer . selectedCard . MoveRight ( count ) ;
736
736
737
+ // After the move, the screen reader will refocus on the other card, but with a little delay. Move the focus
738
+ // to the selected card, but wait a bit to let the first focus change complete. Otherwise, the screen reader
739
+ // will focus on the selected card first, then still on the other card, triggering an infinite swap of the
740
+ // two cards.
737
741
m_MainView . schedule . Execute ( ( ) =>
738
742
AssistiveSupport . notificationDispatcher . SendLayoutChanged ( node )
739
743
) . ExecuteLater ( 50 ) ;
@@ -743,7 +747,8 @@ void MoveCard(bool shouldMoveLeft, int count = 1)
743
747
// TODO: This should be localized.
744
748
var message = $ "Moved { selectedCardText } { ( shouldMoveLeft ? "before" : "after" ) } { otherCardText } ";
745
749
746
- // Announce that the card was moved.
750
+ // Announce that the card was moved. Give a bit of time for the layout change notification to be
751
+ // processed first so that the announcement is not interrupted by the focus change.
747
752
m_MainView . schedule . Execute ( ( ) =>
748
753
AssistiveSupport . notificationDispatcher . SendAnnouncement ( message )
749
754
) . ExecuteLater ( 100 ) ;
You can’t perform that action at this time.
0 commit comments