Skip to content

Commit 1e5ced4

Browse files
author
Bianca Marina Stana
committed
Fixed several screen reader issues during the gameplay
1 parent e95ed02 commit 1e5ced4

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

Assets/Scripts/Gameplay/GameViewController.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,17 +312,18 @@ void MoveCard(bool shouldMoveLeft, int count)
312312
AssistiveSupport.activeHierarchy.MoveNode(element.node, element.node.parent,
313313
element.transform.GetSiblingIndex());
314314

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());
319320
return;
320321

321-
IEnumerator RefreshNodeFrames()
322+
IEnumerator DelaySendLayoutChanged()
322323
{
323324
yield return new WaitForEndOfFrame();
324325

325-
AssistiveSupport.activeHierarchy?.RefreshNodeFrames();
326+
AssistiveSupport.notificationDispatcher.SendLayoutChanged(element.node);
326327
}
327328
}
328329
}

Assets/Scripts/UITk/MainView.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,10 @@ void MoveCard(bool shouldMoveLeft, int count = 1)
734734
m_LetterCardContainer.selectedCard.MoveLeft(count) :
735735
m_LetterCardContainer.selectedCard.MoveRight(count);
736736

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.
737741
m_MainView.schedule.Execute(() =>
738742
AssistiveSupport.notificationDispatcher.SendLayoutChanged(node)
739743
).ExecuteLater(50);
@@ -743,7 +747,8 @@ void MoveCard(bool shouldMoveLeft, int count = 1)
743747
// TODO: This should be localized.
744748
var message = $"Moved {selectedCardText} {(shouldMoveLeft ? "before" : "after")} {otherCardText}";
745749

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.
747752
m_MainView.schedule.Execute(() =>
748753
AssistiveSupport.notificationDispatcher.SendAnnouncement(message)
749754
).ExecuteLater(100);

0 commit comments

Comments
 (0)