Browse Source

only focus code blocks if overflow

Heydon Pickering 8 years ago
parent
commit
ff8f5374b2
3 changed files with 6 additions and 2 deletions
  1. 3 1
      docs/js/dom-scripts.js
  2. 0 0
      docs/service-worker.js
  3. 3 1
      themes/infusion/static/js/dom-scripts.js

+ 3 - 1
docs/js/dom-scripts.js

@@ -117,8 +117,10 @@
   Array.prototype.forEach.call(codeBlocks, function (block) {
     if (block.querySelector('code')) {
       block.setAttribute('role', 'region');
-      block.setAttribute('tabindex', '0');
       block.setAttribute('aria-label', 'code sample');
+      if (block.scrollWidth > block.clientWidth) {
+        block.setAttribute('tabindex', '0');
+      }
     }
   });
 }());

File diff suppressed because it is too large
+ 0 - 0
docs/service-worker.js


+ 3 - 1
themes/infusion/static/js/dom-scripts.js

@@ -117,8 +117,10 @@
   Array.prototype.forEach.call(codeBlocks, function (block) {
     if (block.querySelector('code')) {
       block.setAttribute('role', 'region');
-      block.setAttribute('tabindex', '0');
       block.setAttribute('aria-label', 'code sample');
+      if (block.scrollWidth > block.clientWidth) {
+        block.setAttribute('tabindex', '0');
+      }
     }
   });
 }());

Some files were not shown because too many files changed in this diff