Skip to content

Commit cd5ccf3

Browse files
MelvinBotsituchan
andcommitted
Add comments explaining magic numbers in accessibility announcement
Clarify why timeRemaining === 1 (not 0) is used for expiration check and why timeRemaining % 10 === 1 triggers announcements every 10s. Co-authored-by: Situ Chandra Shil <situchan@users.noreply.github.com>
1 parent 3b6145e commit cd5ccf3

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

  • src/components/ValidateCodeCountdown

src/components/ValidateCodeCountdown/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ function ValidateCodeCountdown({onCountdownFinish, ref}: ValidateCodeCountdownPr
2828
};
2929
}, [onCountdownFinish, timeRemaining]);
3030

31-
// Announce countdown start/reset/expiration for screen readers
31+
// Announce countdown start/reset/expiration for screen readers.
32+
// We check timeRemaining === 1 (not 0) because the component unmounts immediately at 0s, so the expired announcement wouldn't be spoken.
33+
// We use timeRemaining % 10 === 1 to announce every 10 seconds (at 21s, 11s, 1s) to avoid overwhelming screen reader users.
3234
useAccessibilityAnnouncement(
3335
timeRemaining === 1 ? translate('validateCodeForm.timeExpiredAnnouncement') : translate('validateCodeForm.timeRemainingAnnouncement', {timeRemaining: timeRemaining - 1}),
3436
timeRemaining % 10 === 1,

0 commit comments

Comments
 (0)