diff --git a/client/src/templates/Challenges/components/prism-formatted.tsx b/client/src/templates/Challenges/components/prism-formatted.tsx index e95673c1084..f8189939168 100644 --- a/client/src/templates/Challenges/components/prism-formatted.tsx +++ b/client/src/templates/Challenges/components/prism-formatted.tsx @@ -27,6 +27,15 @@ function PrismFormatted({ if (instructionsRef.current) { Prism.hooks.add('complete', enhancePrismAccessibility); Prism.highlightAllUnder(instructionsRef.current); + + const preElements = instructionsRef.current.querySelectorAll('pre'); + preElements.forEach((pre: HTMLPreElement) => { + if (pre.scrollWidth > pre.clientWidth) { + pre.setAttribute('tabIndex', '0'); + } else { + pre.removeAttribute('tabIndex'); + } + }); } }, []);