Guest Posted June 11, 2021 Share Posted June 11, 2021 How might one add keyboard navigation to the Hamburger menu open and close button? I have been able to implement keyboard navigation everywhere else except on the mobile header navigation 'Menu' and 'Close' Link to comment
Guest Posted June 15, 2021 Share Posted June 15, 2021 @tcp13 Any insight on how to implement this ADA related improvement on Mobile Halo Menu Open and Close button? Link to comment
tcp13 Posted June 15, 2021 Share Posted June 15, 2021 (edited) Hi @Kurt12345678, Can you post or DM me a link to your site? We've got some free code in the bonus section of this article for desktop dropdown navigation accessibility, but the fix for mobile depends on which template you're using. Edited June 15, 2021 by tcp13 The above post may be outdated. I’m no longer active in the Squarespace ecosystem, so I won’t see your direct messages. For better resources about web accessibility, I’ve documented some of my thoughts on my forum profile. Link to comment
creedon Posted June 16, 2021 Share Posted June 16, 2021 Please post publicly if you can because I'd like to learn about this issue. Others may as well. sayreambrosio and tcp13 2 Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects. Link to comment
Guest Posted June 17, 2021 Share Posted June 17, 2021 On 6/15/2021 at 1:18 PM, tcp13 said: Can you post or DM me a link to your site? Domain: https://www.hyperionchiropractic.com/ Live Theme: Version 7.0– Five family (Five template) Looking to accomplish this: Success Criterion 3.2.1 On Focus - https://www.w3.org/TR/WCAG21/#on-focus Link to comment
tcp13 Posted June 18, 2021 Share Posted June 18, 2021 (edited) @Kurt12345678 Try adding the following within Settings > Advanced > Code Injection: <!-- jQuery --> <script src="https://code.jquery.com/jquery-3.5.0.min.js"></script> <!-- Accessible Mobile Navigation - Five Template --> <script> // assign role=button so screen readers announce the label as a button $("#mobile-navigation-label").attr("role", "button"); // assign an aria-label as an invisible screen reader label so the button isn't empty $("#mobile-navigation-label").attr("aria-label", "toggle mobile navigation menu"); // add tabindex value so button is focusable by keyboard navigation $("#mobile-navigation-label").attr("tabindex", "0"); // add event listener so button can be triggered by pressing enter or space keys $("#mobile-navigation-label").keyup(function(event) { event.preventDefault(); if (event.keyCode == 13 || event.keyCode == 32) { document.activeElement.click(); } }); </script> With this expected result using exclusively keyboard navigation: This code is based on the standardized WAI-ARIA design pattern for a button: https://www.w3.org/TR/wai-aria-practices/#button You cited WCAG Success Criterion 3.2.1, but I don't think that's applicable here (it prohibits a change of context, such as if focusing the button caused the menu to automatically open without pressing enter). More pertinent are 2.1.1 and 4.1.2 😎 Regardless though, good on ya for being proactive about accessibility! Hope this helps! -Tyler Edited June 18, 2021 by tcp13 paul2009 and creedon 2 The above post may be outdated. I’m no longer active in the Squarespace ecosystem, so I won’t see your direct messages. For better resources about web accessibility, I’ve documented some of my thoughts on my forum profile. Link to comment
Guest Posted June 18, 2021 Share Posted June 18, 2021 17 hours ago, tcp13 said: <!-- jQuery --> <script src="https://code.jquery.com/jquery-3.5.0.min.js"></script> <!-- Accessible Mobile Navigation - Five Template --> <script> // assign role=button so screen readers announce the label as a button $("#mobile-navigation-label").attr("role", "button"); // assign an aria-label as an invisible screen reader label so the button isn't empty $("#mobile-navigation-label").attr("aria-label", "toggle mobile navigation menu"); // add tabindex value so button is focusable by keyboard navigation $("#mobile-navigation-label").attr("tabindex", "0"); // add event listener so button can be triggered by pressing enter or space keys $("#mobile-navigation-label").keyup(function(event) { event.preventDefault(); if (event.keyCode == 13 || event.keyCode == 32) { document.activeElement.click(); } }); </script> Confirming the code worked as needed when added to the Footer block of Code Injection. Thanks @tcp13 Link to comment
creedon Posted January 17 Share Posted January 17 44 minutes ago, studio5design said: Can you please help me find the right selector for this? Please see @paul2009's How to post a forum question. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects. Link to comment
studio5design Posted January 17 Share Posted January 17 6 minutes ago, creedon said: Please see @paul2009's How to post a forum question. How is that helpful? Is posing a question on a public thread illegal somehow? Link to comment
studio5design Posted January 17 Share Posted January 17 I found another solution that worked here, and included the current selectors for SQSP 7.0, using the Five family of templates: https://jolsonweddings.com/education/squarespace-buttons-accessible-name Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment