1
0
mirror of https://github.com/hakimel/reveal.js.git synced 2025-10-25 20:26:36 +02:00

prevent iframes from auto-focusing and disabling keyboard nav, controllable via preventIframeAutoFocus

This commit is contained in:
Hakim El Hattab
2025-09-16 12:05:59 +02:00
parent 8bb6674303
commit c9d6785df2
6 changed files with 25 additions and 4 deletions

View File

@@ -468,6 +468,24 @@ export default class SlideContent {
let iframe = event.target;
if( this.Reveal.getConfig().preventIframeAutoFocus ) {
let elapsed = 0;
const interval = 100;
const maxTime = 1000;
const checkFocus = () => {
if( document.activeElement === iframe ) {
document.activeElement.blur();
} else if( elapsed < maxTime ) {
elapsed += interval;
setTimeout( checkFocus, interval );
}
};
setTimeout( checkFocus, interval );
}
if( iframe && iframe.contentWindow ) {
let isAttachedToDOM = !!closest( event.target, 'html' ),