a11y: add keyboard navigation for extra actions menu opener (#68301)

This commit is contained in:
Frédéric Péters 2022-08-19 17:46:03 +02:00
parent ba02d038f7
commit ad04de1273
1 changed files with 19 additions and 1 deletions

View File

@ -492,10 +492,28 @@ var gadjo_js = gadjo_js || {};
}
});
$(function() {
$('#main-content').on('click', 'a.extra-actions-menu-opener', function() {
$(document.querySelectorAll('.extra-actions-menu')).each(function(i, el) {
this.setAttribute('id', 'extra-actions-menu');
});
$(document.querySelectorAll('.extra-actions-menu-opener')).each(function(i, el) {
this.setAttribute('tabindex', 0);
this.setAttribute('aria-label', 'Menu'); // XXX: translation
this.setAttribute('aria-controls', 'extra-actions-menu');
this.setAttribute('aria-expanded', 'false');
this.addEventListener('keydown', function(e) {
if (e.key === 'Enter' || e.key === ' ') {
$(this).toggleClass('open');
$('.extra-actions-menu').toggleClass('open');
this.setAttribute('aria-expanded', $(this).is('.open'));
e.preventDefault();
}
});
this.addEventListener('click', function() {
$(this).toggleClass('open');
$('.extra-actions-menu').toggleClass('open');
this.setAttribute('aria-expanded', $(this).is('.open'));
});
});
});
$(function() {
$(document).on('click auxclick', '.clickable-rows tr', function(event) {