Additional keyboard accessibility for Slack popup

Signed-off-by: Connor Chan <connorjosephchan@gmail.com>
This commit is contained in:
Connor Chan 2020-11-19 17:25:23 -05:00
parent 91375fb066
commit 6cfc34597d
No known key found for this signature in database
GPG Key ID: C61FF92DDE2DA2A6
1 changed files with 10 additions and 0 deletions

View File

@ -7,7 +7,15 @@
return window.localStorage.getItem('dismissedSlackPopup') === 'true';
}
function handleEscapeKey(e) {
if (e.key === 'Escape') {
hidePopup();
}
}
function hidePopup() {
document.removeEventListener('keydown', handleEscapeKey);
// IE fix
document.querySelector('.slack-popup-container').innerHTML = '';
@ -90,6 +98,8 @@
popup.appendChild(popupBody);
document.querySelector('body').appendChild(popup);
document.addEventListener('keydown', handleEscapeKey);
}
}