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

Better focus management for a11y #259

Open
mrwweb opened this issue Nov 3, 2016 · 13 comments
Open

Better focus management for a11y #259

mrwweb opened this issue Nov 3, 2016 · 13 comments

Comments

@mrwweb
Copy link

mrwweb commented Nov 3, 2016

What kind of issue is this? (put 'x' between the square brackets)

This is half-feature-request-half-bug since bad focus management is really bad for accessibility. As detailed in "Learning to focus()", when users toggle open the lightbox, the keyboard focus should be shifted to/inside the modal. Just as importantly, focus should be returned to the element that triggered the lightbox when it's closed.

Yes, this could be implemented with custom functions and the available events provided by featherlight (as in #151), but there's no reason why it shouldn't be baked in. I could even imagine a shiftFocusTo argument with a select for specifying the best element in the lightbox to receive focus (form field, close button, etc.)

See also: "Managing focus for modal dialogs"

@marcandre
Copy link
Collaborator

I agree. PR anyone?

@marcandre
Copy link
Collaborator

I have solutions to #259 and #260 in the accessibility branch. Just have to figure out the exact rules for autofocus so the focus is shifted properly to inside the dialog.

@marcandre
Copy link
Collaborator

For focus management, here's what I've coded in the accessibility branch:

  • clear & reset focus on open/close dialog
  • focus on any [autofocus] element inside the dialog if any
  • insure that pressing tab won't focus on an element outside the dialog.

How does that sound, @mrwweb ?

@mrwweb
Copy link
Author

mrwweb commented Nov 16, 2016

Sounds about right! I appreciate the quick response to these issues. Hope they can benefit everyone.

@marcandre
Copy link
Collaborator

Cool. Published 1.6.0

@robneu
Copy link

robneu commented Nov 17, 2016

Maybe I'm missing something, but this change seems to make it impossible to focus on the close button while using the keyboard.

@robneu
Copy link

robneu commented Nov 17, 2016

Similarly, it also doesn't seem possible to focus on the next/prev buttons in the gallery when one is active and I guess those spans should probably also be updated to use button elements.

@marcandre
Copy link
Collaborator

Mmm, you're right, the close button has a tabindex="-1".
Let me see about the prev/next buttons too...

@marcandre
Copy link
Collaborator

Fixed and released.
I also realized that I was nuking any tabindex, fixed too.

@robneu
Copy link

robneu commented Nov 18, 2016

Sorry to keep hounding on this issue, but while the internal focus management seems improved in 1.6.1 when the lightbox is closed the focus isn't restored to the previously focused element correctly.

When the normal content is brought back into focus, the element in focus when the lightbox was triggered should regain focus. Right now, when the lightbox closes focus returns to the beginning of the page and the user is forced to tab back through the navigation and content rather than continuing where they left off.

@mrwweb
Copy link
Author

mrwweb commented Nov 18, 2016

Right now, when the lightbox closes focus returns to the beginning of the page and the user is forced to tab back through the navigation and content rather than continuing where they left off.

Yup. That was one of the primary points of the original ticket. Thanks, @robneu!

@robneu
Copy link

robneu commented Nov 18, 2016

This example has a couple weird things going on, but the focus management seems about right: http://fnagel.github.io/jQuery-Accessible-RIA/Lightbox/

@marcandre
Copy link
Collaborator

Mmm, it's possible that it focusses on the first item, my test has only one item! Let me check

@marcandre marcandre reopened this Nov 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants