jquery.localScroll icon indicating copy to clipboard operation
jquery.localScroll copied to clipboard

Accessibility and Keyboard navigation

Open NickStees opened this issue 5 years ago • 3 comments

So I have to remove this from my site because it is causing issues with our keyboard users and skip navigation links, after they "skip" to the main content, the focus returns to the top of the document so it does not help them skip anything. Is there a way to set the focus properly after they scroll so their keyboard navigation can pick up where it should on the page? Maybe using .focus({preventScroll:true}); after this feature finishes?

NickStees avatar Feb 27 '19 21:02 NickStees

You would also have to make sure the element that has the ID being scrolled to is focusable.. I.e. if not a link, then it should have a tabindex="-1", otherwise the call to .focus() will fail with an error in the console.

tmorehouse avatar Feb 27 '19 22:02 tmorehouse

@tmorehouse Thanks for the tabindex info! The skip nav typically goes to a <main id="main"> so I guess I would need to add at tabindex="-1" like you mentioned. If the LocalScroll doesn't need modified to support key board navigation and there is another means I am all ears! I really would like to keep using the Library because of my sites static header.

NickStees avatar Feb 28 '19 02:02 NickStees

It might be worth checking how popular sites implement skip-to-main links. For example, GitHub has a “Skip to content” control that seems to focus this element:

<div id="js-flash-container" tabindex="-1"></div>

which is located immediately before the main content (<div class="application-main">).

simevidas avatar Apr 20 '19 16:04 simevidas