Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lex111 committed Oct 26, 2020
1 parent 6c55180 commit 4d5b422
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ function useKeyboardNavigation(): void {
const keyboardFocusedClassName = 'navigation-with-keyboard';

function handleOutlineStyles(e: MouseEvent | KeyboardEvent) {
document.body.classList.toggle(keyboardFocusedClassName, e.key === 'Tab');
if (e.type === 'keydown' && (e as KeyboardEvent).key === 'Tab') {
document.body.classList.add(keyboardFocusedClassName);
}

if (e.type === 'mousedown') {
document.body.classList.remove(keyboardFocusedClassName);
}
}

document.addEventListener('keydown', handleOutlineStyles);
Expand Down

0 comments on commit 4d5b422

Please sign in to comment.