Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus not moved when lightbox is loaded #190

Closed
tomkiss opened this issue Aug 12, 2020 · 3 comments
Closed

Focus not moved when lightbox is loaded #190

tomkiss opened this issue Aug 12, 2020 · 3 comments
Assignees

Comments

@tomkiss
Copy link

tomkiss commented Aug 12, 2020

Hi there,

There is a missing accessibility opportunity on simple lightbox.

When the lightbox is loaded, the focus remains on the previously clicked/selected element.

This prevents the user from being able to tab to the close or other buttons, for more accessible keyboard control.

A common way to achieve this is to:

  • When a link or button is clicked to launch the lightbox, record the triggering element from event.target.
  • Shift focus to the containing element of the lightbox (tabindex="0" may be required to achieve this).
  • When the lightbox is closed, return focus() to the previously clicked element, using the recorded value.

This should enable the user to launch the lightbox via the keyboard, navigate and interact with it and then close it without a cursor input device, helping to improve accessibility support.

The outline: none on the :focus pseudo-element would also need updating.

@andreknieriem
Copy link
Owner

Hey, interesting idea. I will take a look.

@andreknieriem
Copy link
Owner

Sorry, I just wanted to do this, but why? If the lightbox is open you don't need to tab. Just use the arrow keys or the escape key to use the lightbox.

@tomkiss
Copy link
Author

tomkiss commented Oct 21, 2020

Well, it's the subtle difference between keyboard shortcuts and the user being able to tab-navigate the interface which they are presented with. There's no visual clue or instruction that ESC will close the lightbox, but there is a close icon, which they are unable to access without a pointer device.

Another way to look at the same problem is that the focused element is still outside the lightbox, so tab navigation continues to be able to browse and navigate the page underneath the lightbox, whilst it is active.

Accessibility Insights is a useful tool for identifying and fixing a broad range of accessibility issues on websites. I hope this is helpful.

andreknieriem pushed a commit that referenced this issue Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants