biati-digital / glightbox

Pure Javascript lightbox with mobile support. It can handle images, videos with autoplay, inline content and iframes
MIT License
2.07k stars 228 forks source link

Focus should be restored to original position after closing modal #351

Closed cmachanic closed 1 year ago

cmachanic commented 2 years ago

Describe the bug If you close the modal when navigating via a keyboard, the tab order returns to the top of the page.

Are you able to reproduce the bug in the demo site Yes

To Reproduce Steps to reproduce the behavior:

  1. Open a photo in the modal
  2. Tab to the close button to close the modal
  3. Continue tabbing where you left off, and you'll find yourself tabbing from the top of the DOM

Expected behavior You should return to your original position in the tab order prior to opening the modal.

Desktop:

gingerchew commented 2 years ago

A bit of a patch was talked about in this discussion thread, in case anyone is looking for a possible fix in the mean time.

I haven't had a chance to test it with a screen reader, but it should work for moving focus around.

If someone is having an issue implementing the patch, open a discussion thread and we can try and work it out, seeing as it is unofficial :)

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.