Skip to content

Commit

Permalink
A11y: add keydown escape for manager main nav modxcms#16612
Browse files Browse the repository at this point in the history
  • Loading branch information
jenswittmann committed Sep 12, 2024
1 parent b993603 commit 96e2542
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions manager/assets/modext/core/modx.layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,22 @@ Ext.extend(MODx.Layout, Ext.Viewport, {
return;
}
if (!submenu.contains(document.activeElement)) {
this.focusRestoreEls.pop()?.focus();
this.focusRestoreEls?.pop()?.focus();
this.hideMenu();
window.removeEventListener('focusout', focusRestore);
}
}, 1);
};
var menuArrowKeysNavigation = (e) => {
if (e.code == 'Escape') {
this.hideMenu();
this.focusRestoreEls[0]?.focus();
this.focusRestoreEls = [];
window.removeEventListener('keyup', menuArrowKeysNavigation);
}
};
window.addEventListener('focusout', focusRestore);
window.addEventListener('keyup', menuArrowKeysNavigation);
}
this.hideSubMenu();
}
Expand Down Expand Up @@ -578,9 +587,9 @@ Ext.extend(MODx.Layout, Ext.Viewport, {
var focusRestore = (e) => {
requestAnimationFrame(() => {
if (!menu.contains(document.activeElement)) {
_this.focusRestoreEls?.pop()?.parentNode?.nextSibling?.focus();
hide(button);
window.removeEventListener('focusout', focusRestore);
_this.focusRestoreEls.pop()?.parentNode?.nextSibling?.focus();
}
});
};
Expand Down

0 comments on commit 96e2542

Please sign in to comment.