@@ -8,6 +8,7 @@ declare global {
88 RevealDrop ?: {
99 id : string ;
1010 dropElement : HTMLDivElement ;
11+ focusElement : Element | null ;
1112 init : ( reveal : any ) => void ;
1213 toggleDrop : ( ) => void ;
1314 isActive : ( ) => boolean ;
@@ -33,6 +34,7 @@ type DropConfig = {
3334
3435window . RevealDrop = window . RevealDrop || {
3536 id : 'RevealDrop' ,
37+ focusElement : null ,
3638 dropElement : document . createElement ( 'div' ) ,
3739 init : function ( reveal ) {
3840 const revealConfig = reveal . getConfig ( ) ;
@@ -83,12 +85,26 @@ window.RevealDrop = window.RevealDrop || {
8385 window . RevealDrop . toggleDrop ( ) ;
8486 reveal . toggleHelp ( false ) ;
8587 reveal . toggleOverview ( false ) ;
86- reveal . configure ( { keyboard : ! window . RevealDrop . isActive ( ) } ) ;
88+
89+ if ( window . RevealDrop . isActive ( ) ) {
90+ reveal . configure ( { keyboard : false } ) ;
91+ // Restore focus as console is shown
92+ if ( window . RevealDrop . focusElement instanceof HTMLElement ) {
93+ window . RevealDrop . focusElement . focus ( ) ;
94+ }
95+ } else {
96+ reveal . configure ( { keyboard : true } ) ;
97+ // Remove focus as console is hidden
98+ window . RevealDrop . focusElement = document . activeElement ;
99+ if ( document . activeElement instanceof HTMLElement ) {
100+ document . activeElement . blur ( ) ;
101+ }
102+ }
103+
87104 event . preventDefault ( ) ;
88105 event . stopPropagation ( ) ;
89106 }
90107 } , { capture : true } ) ;
91-
92108 } ,
93109 toggleDrop ( ) {
94110 window . RevealDrop . dropElement . classList . toggle ( "active" ) ;
0 commit comments