Tagged: accessibility, Barrierefreiheit
In the context of accessibility, it should be possible to close open drop-down menus with keyboard control via ESC. This does not work with Enfold. Is there any idea how I can implement this?
Hey togetherconcept,
Thank you for the inquiry.
Try to add this script in the functions.php file:
function ava_custom_accessibility_script() {
?>
<script>
(function($) {
$(document).ready(function() {
$(document).keydown(function(e) {
if (e.keyCode === 27) {
$('.menu-item-has-children').each(function() {
var $submenu = $(this).find('.sub-menu');
if ($submenu.css('opacity') === '1') {
$submenu.css({
'opacity': '0',
'visibility': 'hidden'
});
}
});
}
});
});
})(jQuery);
</script>
<?php
}
add_action('wp_footer', 'ava_custom_accessibility_script');
Best regards,
Ismael
Thanks a lot. It works fine!
I’m sorry, but I’ve just discovered a new problem with the php code. In the smartphone view, the submenus with this code are no longer displayed at all. the previously required space remains free, they are probably hidden.
Hi,
Thank you for the update.
The script above should not affect the behavior of the submenus in mobile view. Would you mind providing a screenshot of the issue? You can use platforms like Savvyify, Imgur, or Dropbox. The submenus were still visible inside the burger menu when we checked.
Best regards,
Ismael
Hi,
UPDATE: We may have found the issue with the script and edited it a bit — please try it again.
Best regards,
Ismael
Thanks a lot,
the magic happened. Everthing works fine!
Regards
Stephan