Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.1] A11y/ManagerMenu: hotfix for links not clickable 3th level #16671

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions manager/assets/modext/core/modx.layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,9 @@ Ext.extend(MODx.Layout, Ext.Viewport, {
,splitBarMargin: 8

/**
* @property {Array} focusRestoreEls - Set Focus back on the last Element in array on close
* @property {Object} focusRestoreEl - Set Focus back on this Element
*/
,focusRestoreEls: []

/**
* @property {bool} subNavOpen - Check if Subnav is opened
*/
,subNavOpen: false
,focusRestoreEl: []

/**
* @property {Function} getSplitBarMargin - Utility getter for splitBarMargin
Expand Down Expand Up @@ -493,9 +488,9 @@ Ext.extend(MODx.Layout, Ext.Viewport, {
}
}
});
buttons[i].addEventListener('click', function (e) {
buttons[i].addEventListener('click', function(e) {
e.stopPropagation();
el.focusRestoreEls.push(this.querySelectorAll('a')[0]);
el.focusRestoreEl = this.querySelectorAll('a')[0];
el.showMenu(this);
});
}
Expand All @@ -514,30 +509,38 @@ Ext.extend(MODx.Layout, Ext.Viewport, {
submenu.classList.remove('active');
} else {
this.hideMenu();
var isClick = false;
submenu.classList.add('active');
setTimeout(() => {
submenu.querySelectorAll('a')[0].focus();
var firstFocusEl = submenu.querySelectorAll('a')[0];
if (!firstFocusEl) {
return;
}
firstFocusEl.focus();
}, 50);
var menuItemClicked = (e) => {
isClick = true;
window.removeEventListener('click', menuItemClicked);
};
var focusRestore = (e) => {
setTimeout(() => {
if (this.subNavOpen) {
return;
}
requestAnimationFrame(() => {
if (!submenu.contains(document.activeElement)) {
this.focusRestoreEls?.pop()?.focus();
if (!isClick) {
this.focusRestoreEl?.focus();
}
this.hideMenu();
window.removeEventListener('focusout', focusRestore);
}
}, 1);
});
};
var menuArrowKeysNavigation = (e) => {
if (e.code == 'Escape') {
this.hideMenu();
this.focusRestoreEls[0]?.focus();
this.focusRestoreEls = [];
this.focusRestoreEl?.focus();
window.removeEventListener('keyup', menuArrowKeysNavigation);
}
};
window.addEventListener('click', menuItemClicked);
window.addEventListener('focusout', focusRestore);
window.addEventListener('keyup', menuArrowKeysNavigation);
}
Expand All @@ -552,7 +555,6 @@ Ext.extend(MODx.Layout, Ext.Viewport, {
,initSubPopper: function () {
var buttons = document.querySelectorAll('#modx-header .sub, #modx-footer .sub');
var position = window.innerWidth <= 960 ? 'bottom' : 'right';
var _this = this;
for (var i = 0; i < buttons.length; i++) {
let popperInstance = null;

Expand Down Expand Up @@ -595,17 +597,14 @@ Ext.extend(MODx.Layout, Ext.Viewport, {
}

function show(button) {
var menu = button.getElementsByTagName('ul')[0];
var submenu = button.getElementsByTagName('ul')[0];
button.classList.add('active');
menu.classList.add('active');
_this.focusRestoreEls.push(button.querySelectorAll('a')[0]);
_this.subNavOpen = true;
create(button, menu);
submenu.classList.add('active');
create(button, submenu);
var focusRestore = (e) => {
requestAnimationFrame(() => {
if (!menu.contains(document.activeElement)) {
_this.focusRestoreEls?.pop()?.parentNode?.nextSibling?.focus();
hide(button);
if (!submenu.contains(document.activeElement)) {
submenu.classList.remove('active');
window.removeEventListener('focusout', focusRestore);
}
});
Expand All @@ -623,7 +622,6 @@ Ext.extend(MODx.Layout, Ext.Viewport, {
submenu.removeAttribute('style');
buttons[i].classList.remove('active');
}
_this.subNavOpen = false;
destroy();
}
buttons[i].addEventListener('mouseenter', function (e) {
Expand All @@ -632,7 +630,9 @@ Ext.extend(MODx.Layout, Ext.Viewport, {
});
buttons[i].querySelectorAll('a')[0].addEventListener('focus', function (e) {
e.stopPropagation();
show(this.parentNode);
requestAnimationFrame(() => {
show(this.parentNode);
});
});
buttons[i].addEventListener('mouseleave', function (e) {
e.stopPropagation();
Expand Down
4 changes: 2 additions & 2 deletions manager/assets/modext/modx.jsgrps-min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion manager/templates/default/css/index-min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manager/templates/default/css/index.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2024 MODX LLC
* Copyright (C) 2025 MODX LLC
*
* This file is part of MODX Revolution and was compiled using Grunt.
*
Expand Down
2 changes: 1 addition & 1 deletion manager/templates/default/css/login-min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion manager/templates/default/css/login.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2024 MODX LLC
* Copyright (C) 2025 MODX LLC
*
* This file is part of MODX Revolution and was compiled using Grunt.
*
Expand Down
9 changes: 1 addition & 8 deletions manager/templates/default/footer.tpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
</div>
<!-- #modx-content-->
<div id="modx-footer">
{if $_search}
<div class="modx-subnav" id="modx-manager-search-icon-submenu">
<div class="modx-subnav-arrow"></div>
<div id="modx-manager-search" role="search"></div>
</div>
{/if}
</div>
<div id="modx-footer"></div>
</div>
<!-- #modx-container -->

Expand Down
6 changes: 6 additions & 0 deletions manager/templates/default/header.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@
</li>
{/if}
</ul>
{if $_search}
<div class="modx-subnav" id="modx-manager-search-icon-submenu">
<div class="modx-subnav-arrow"></div>
<div id="modx-manager-search" role="search"></div>
</div>
{/if}
<ul id="modx-topnav">
{eval var=$navb}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion setup/assets/css/installer-min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion setup/assets/css/installer.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2024 MODX LLC
* Copyright (C) 2025 MODX LLC
*
* This file is part of MODX Revolution and was compiled using Grunt.
*
Expand Down