File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
docs/.vuepress/theme/layouts Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -282,8 +282,18 @@ export default {
282282
283283 this .$router .afterEach (() => {
284284 this .isSidebarOpen = false ;
285+ this .$nextTick (() => {
286+ this .makeScrollingCodeBlocksFocusable ();
287+ });
288+
285289 });
286290
291+ this .$nextTick (() => {
292+ this .makeScrollingCodeBlocksFocusable ();
293+ });
294+
295+ this .makeScrollingCodeBlocksFocusable ();
296+
287297 // temporary means of scrolling to URL hash on load
288298 // https://github.com/vuejs/vuepress/issues/2428
289299 const hash = document .location .hash ;
@@ -364,6 +374,14 @@ export default {
364374 },
365375
366376 methods: {
377+ makeScrollingCodeBlocksFocusable () {
378+ document .querySelectorAll (' pre' ).forEach (el => {
379+ if (el .scrollWidth > el .clientWidth ) {
380+ el .setAttribute (' tabindex' , ' 0' );
381+ }
382+ });
383+ },
384+
367385 toggleSidebar (to ) {
368386 this .temporarilyAnimateBody ();
369387 this .isSidebarOpen = typeof to === " boolean" ? to : ! this .isSidebarOpen ;
You can’t perform that action at this time.
0 commit comments