Skip to content

Commit c9d6785

Browse files
committed
prevent iframes from auto-focusing and disabling keyboard nav, controllable via preventIframeAutoFocus
1 parent 8bb6674 commit c9d6785

File tree

6 files changed

+25
-4
lines changed

6 files changed

+25
-4
lines changed

dist/reveal.esm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/reveal.esm.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/reveal.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/reveal.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ export default {
168168
// - false: All iframes with data-src will be loaded only when visible
169169
preloadIframes: null,
170170

171+
// Prevent embedded iframes from automatically focusing on themselves
172+
preventIframeAutoFocus: true,
173+
171174
// Can be used to globally disable auto-animation
172175
autoAnimate: true,
173176

js/controllers/slidecontent.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,24 @@ export default class SlideContent {
468468

469469
let iframe = event.target;
470470

471+
if( this.Reveal.getConfig().preventIframeAutoFocus ) {
472+
473+
let elapsed = 0;
474+
const interval = 100;
475+
const maxTime = 1000;
476+
const checkFocus = () => {
477+
if( document.activeElement === iframe ) {
478+
document.activeElement.blur();
479+
} else if( elapsed < maxTime ) {
480+
elapsed += interval;
481+
setTimeout( checkFocus, interval );
482+
}
483+
};
484+
485+
setTimeout( checkFocus, interval );
486+
487+
}
488+
471489
if( iframe && iframe.contentWindow ) {
472490

473491
let isAttachedToDOM = !!closest( event.target, 'html' ),

0 commit comments

Comments
 (0)