Merge pull request #253 from octfx/dev

refactor: Hide drawer on esc and outside click
This commit is contained in:
alistair3149 2021-01-29 13:09:05 -05:00 committed by GitHub
commit 44811362c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,6 +40,18 @@ function init() {
personalMenuCheckbox = document.getElementById( PERSONAL_MENU_CHECKBOX_ID );
uncheckOnClickOutside( drawer, drawerButton, drawerCheckbox );
uncheckOnClickOutside( personalMenu, personalMenuButton, personalMenuCheckbox );
drawer.addEventListener( 'click', function ( event ) {
if ( typeof event.target !== 'undefined' && event.target.id === DRAWER_ID ) {
drawerCheckbox.checked = false;
}
} );
document.addEventListener( 'keydown', function ( event ) {
if ( event.key === 'Escape' && drawerCheckbox.checked === true ) {
drawerCheckbox.checked = false;
}
} );
}
module.exports = {