
-
AuthorPosts
-
April 24, 2025 at 2:45 pm #1482184
Hi,
when entering a website a cookie message bar appears at the bottom. If you’re using keyboard it takes at least 30 tab-clicks to get to the message bar.
How can we make cookie message bar the ‘first in line’ when using keyboard, so that user can instantly agree/disagree on cookies?Another question is regarding selecting certain cookies in modal pop-up window. When using keyboard I can switch between tabs, but I cannot access the list of cookies to select/deselect them nor the buttons at the bottom to confirm the selection.
Please help.
April 26, 2025 at 5:07 pm #1483226Hey nm,
Thank you for your patience, to move cookie consent bar to top of the DOM so it is first in the tabindex, add the following code to the end of your child theme functions.php file in Appearance ▸ Editor.
The code also adds tabindex to the hidden checkboxes in the moral and hides the “toggle” switches, so the checkboxes can be tabbed to.
When tabbing in the moral you will first be able to tab though the tabs and use the enter key to select one, then keep tabbing to get inside the tab content and tab through the checkboxes. You can use the spacebar to enable/disable the checkboxes.function move_cookie_consent_bar_to_top_of_dom_so_it_is_first_in_tabindex() { ?> <script> document.addEventListener('DOMContentLoaded', function() { const messageBar = document.querySelector('.avia-cookie-consent-wrap'); const body = document.querySelector('body#top'); body.prepend(messageBar); }); document.addEventListener('DOMContentLoaded', () => { document.querySelectorAll('#av-consent-extra-info input[type="checkbox"]').forEach(checkbox => { checkbox.setAttribute('tabindex', '0'); }); }); </script> <style> #top .av-toggle-switch input[type="checkbox"] { display: inline; } #top .av-toggle-switch .toggle-label-content { display: inline; } #top .av-toggle-switch label .toggle-track { display: none; } </style> <?php } add_action( 'wp_footer', 'move_cookie_consent_bar_to_top_of_dom_so_it_is_first_in_tabindex', 99 );
Please ensure to copy the code from the forum and not an email notification so the symbols are not converted.
This may not seem intuitive, so perhaps you will want to try a cookie bar plugin like Borlabs, I don’t know how keyboard tabbing works with it but many Enfold users like it.
If you are happy with just tabbing to accept or reject cookies with just a few tab keys then the above script will work fine, I see that your consent moral only has two checkboxes.Best regards,
Mike -
AuthorPosts
- You must be logged in to reply to this topic.