@@ -296,11 +296,27 @@ export class ChoiceInput extends React.Component {
296296 } ) ,
297297 } ;
298298
299+ const hasMathOrImage =
300+ typeof label === 'string' &&
301+ ( label . includes ( '<math' ) ||
302+ label . includes ( '\\(' ) ||
303+ label . includes ( '\\[' ) ||
304+ label . includes ( '<img' ) ||
305+ label . includes ( 'data-latex' ) ||
306+ label . includes ( 'data-raw' ) ||
307+ label . includes ( '<mjx-container' ) ) ;
308+
309+ const screenReaderLabel = displayKey ? (
310+ < SrOnly id = { this . descId } >
311+ { hasMathOrImage ? `Pick the answer below, ${ displayKey } ` : displayKey }
312+ </ SrOnly >
313+ ) : null ;
314+
299315 const choicelabel = (
300316 < >
301317 { displayKey && ! isSelectionButtonBelow ? (
302318 < Row component = "span" >
303- { displayKey } .{ '\u00A0' }
319+ < span aria-hidden = "true" > { displayKey } .{ '\u00A0' } </ span >
304320 < PreviewPrompt className = "prompt-label" prompt = { label } tagName = "span" />
305321 </ Row >
306322 ) : (
@@ -309,12 +325,6 @@ export class ChoiceInput extends React.Component {
309325 </ >
310326 ) ;
311327
312- const screenReaderLabel = (
313- < SrOnly id = { this . descId } >
314- { choiceMode === 'checkbox' ? 'Checkbox to select the answer below' : 'Radio button to select the answer below' }
315- </ SrOnly >
316- ) ;
317-
318328 const tagProps = {
319329 disabled,
320330 checked,
@@ -324,28 +334,18 @@ export class ChoiceInput extends React.Component {
324334 id : this . choiceId ,
325335 onChange : this . onToggleChoice ,
326336 onKeyDown : this . handleKeyDown ,
327- 'aria-describedby' : this . descId ,
337+ ... ( screenReaderLabel ? { 'aria-describedby' : this . descId } : { } ) ,
328338 } ;
329339
330- const hasMathOrImage =
331- typeof label === 'string' &&
332- ( label . includes ( '<math' ) ||
333- label . includes ( '\\(' ) ||
334- label . includes ( '\\[' ) ||
335- label . includes ( '<img' ) ||
336- label . includes ( 'data-latex' ) ||
337- label . includes ( 'data-raw' ) ||
338- label . includes ( '<mjx-container' ) ) ;
339-
340340 const control = isSelectionButtonBelow ? (
341341 < BelowSelectionComponent >
342- { hasMathOrImage && screenReaderLabel }
342+ { screenReaderLabel }
343343 < Tag { ...tagProps } style = { { padding : 0 } } />
344- { displayKey ? `${ displayKey } .` : '' }
344+ < span aria-hidden = "true" > { displayKey ? `${ displayKey } .` : '' } </ span >
345345 </ BelowSelectionComponent >
346346 ) : (
347347 < >
348- { hasMathOrImage && screenReaderLabel }
348+ { screenReaderLabel }
349349 < Tag { ...tagProps } slotProps = { { input : { ref : this . props . autoFocusRef } } } />
350350 </ >
351351 ) ;
0 commit comments