Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1473022

    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?

    #1473070

    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

    #1473102

    Thanks a lot. It works fine!

    #1473105

    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.

    #1473197

    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

    #1473198

    Hi,

    UPDATE: We may have found the issue with the script and edited it a bit — please try it again.

    Best regards,
    Ismael

    #1473222

    Thanks a lot,
    the magic happened. Everthing works fine!
    Regards
    Stephan

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Close drop-down menus with keyboard control via ESC’ is closed to new replies.