@@ -72,6 +72,9 @@ const RecordingDialog = ({
7272 ) ;
7373 const countdownStages : CountdownStage [ ] = useMemo (
7474 ( ) => [
75+ // Empty string state added to countdown because aria-live role region
76+ // reads dynamic changes to region and not the initial contents.
77+ { value : "" , duration : 1 , fontSize : "8xl" } ,
7578 { value : 3 , duration : 500 , fontSize : "8xl" } ,
7679 { value : 2 , duration : 500 , fontSize : "8xl" } ,
7780 { value : 1 , duration : 500 , fontSize : "8xl" } ,
@@ -241,6 +244,17 @@ const RecordingDialog = ({
241244 return recordingsToCapture - recordingsRemaining ;
242245 } , [ recordingsRemaining , recordingsToCapture ] ) ;
243246
247+ const recordingText = useMemo ( ( ) => {
248+ if ( recordingStatus === RecordingStatus . Recording ) {
249+ return intl . formatMessage ( { id : "recording" } ) ;
250+ } else if ( recordingStatus === RecordingStatus . Countdown ) {
251+ return countdownStages [ countdownStageIndex ] . value ;
252+ } else if ( recordingStatus === RecordingStatus . Done ) {
253+ return intl . formatMessage ( { id : "recording-complete" } ) ;
254+ }
255+ return "" ;
256+ } , [ countdownStageIndex , countdownStages , intl , recordingStatus ] ) ;
257+
244258 return (
245259 < Modal
246260 closeOnOverlayClick = { false }
@@ -273,36 +287,20 @@ const RecordingDialog = ({
273287 < ModalBody py = { 8 } >
274288 < VStack justifyContent = "center" gap = { 5 } >
275289 < VStack h = "20" alignItems = "center" justifyContent = "center" >
276- { recordingStatus === RecordingStatus . Recording && (
277- < Text
278- fontSize = "5xl"
279- textAlign = "center"
280- fontWeight = "bold"
281- color = "brand.500"
282- >
283- < FormattedMessage id = "recording" />
284- </ Text >
285- ) }
286- { recordingStatus === RecordingStatus . Countdown && (
287- < Text
288- fontSize = { countdownStages [ countdownStageIndex ] . fontSize }
289- textAlign = "center"
290- fontWeight = "bold"
291- color = "brand.500"
292- >
293- { countdownStages [ countdownStageIndex ] . value }
294- </ Text >
295- ) }
296- { recordingStatus === RecordingStatus . Done && (
297- < Text
298- fontSize = "5xl"
299- textAlign = "center"
300- fontWeight = "bold"
301- color = "brand.500"
302- >
303- < FormattedMessage id = "recording-complete" />
304- </ Text >
305- ) }
290+ < Text
291+ fontSize = {
292+ recordingStatus === RecordingStatus . Countdown
293+ ? countdownStages [ countdownStageIndex ] . fontSize
294+ : "5xl"
295+ }
296+ textAlign = "center"
297+ fontWeight = "bold"
298+ color = "brand.500"
299+ role = "timer"
300+ aria-live = "assertive"
301+ >
302+ { recordingText }
303+ </ Text >
306304 </ VStack >
307305 < Progress
308306 alignSelf = "center"
0 commit comments