@@ -332,32 +332,19 @@ <h3 class="anchored" data-anchor-id="my-autograder-keeps-runningtimed-out">My au
332332 }
333333 } ) ;
334334
335- // 1. Target all code blocks (Source Code and Code Output <pre> elements)
336- // that are scrollable (have overflow:auto/scroll).
337- var scrollableRegions = document . querySelectorAll (
338- // 1. Source Code <pre>
339- 'div.sourceCode > pre, ' +
340- // 2. Output <pre> inside a generic cell-output
341- '.cell-output > pre, ' +
342- // 3. The main DIV container for cell-output-display (from previous fix)
343- '.cell-output-display.cell-output, ' +
344- // 4. PRE tag inside any ANSI-escaped output (e.g., .ansi-escaped-output > pre)
345- '.ansi-escaped-output > pre, ' +
346- // 5. The deepest container for error output (e.g., #ID > .cell-output-error... > .ansi-escaped-output > pre)
347- '.cell-output-error.cell-output > .ansi-escaped-output > pre, ' +
348- // Target any PRE tag that has an ID attribute
349- 'pre[id], ' +
350- // code blocks inside list items
351- 'li > pre, ' +
352- // PRE tags within an output display container
353- '.cell-output-display > pre'
354- ) ;
335+ // Scrollable Region Accessibility Fix:
336+ // Target ALL <pre> elements, as they are the source of the scrollable-region-focusable errors.
337+ var scrollableRegions = document . querySelectorAll ( 'pre' ) ;
355338
356339 scrollableRegions . forEach ( function ( region ) {
357- // Check if the element actually has horizontal overflow (is scrollable)
358- // Add tabindex="0" to make the region keyboard-focusable.
359- if ( region . getAttribute ( 'tabindex' ) === null || region . getAttribute ( 'tabindex' ) === undefined ) {
360- region . setAttribute ( 'tabindex' , '0' ) ;
340+ // Check if the element has horizontal overflow (is scrollable).
341+ const hasScrollbar = region . scrollWidth > region . clientWidth || region . scrollHeight > region . clientHeight ;
342+
343+ if ( hasScrollbar ) {
344+ // If it is scrollable AND it doesn't already have tabindex="0" (or a different value)
345+ if ( region . getAttribute ( 'tabindex' ) === null || region . getAttribute ( 'tabindex' ) === undefined ) {
346+ region . setAttribute ( 'tabindex' , '0' ) ;
347+ }
361348 }
362349 } ) ;
363350} ) ;
0 commit comments