Improved accessibility for many editor page components

Related to #1320
This commit is contained in:
Dan Brown
2019-08-26 12:47:04 +01:00
parent 7cc17934a8
commit 64abe10dc4
8 changed files with 38 additions and 24 deletions

View File

@ -118,8 +118,8 @@ class DropDown {
}
});
// Arrow navigation
this.container.addEventListener('keydown', event => {
// Keyboard navigation
const keyboardNavigation = event => {
if (event.key === 'ArrowDown' || event.key === 'ArrowRight') {
this.focusNext();
event.preventDefault();
@ -128,9 +128,14 @@ class DropDown {
event.preventDefault();
} else if (event.key === 'Escape') {
this.hide();
this.toggle.focus();
event.stopPropagation();
}
});
};
this.container.addEventListener('keydown', keyboardNavigation);
if (this.moveMenu) {
this.menu.addEventListener('keydown', keyboardNavigation);
}
// Hide menu on enter press or escape
this.menu.addEventListener('keydown ', event => {