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

Lost focus when closing the modal #547

Open
aloayzab88 opened this issue Jan 29, 2025 · 2 comments
Open

Lost focus when closing the modal #547

aloayzab88 opened this issue Jan 29, 2025 · 2 comments

Comments

@aloayzab88
Copy link

aloayzab88 commented Jan 29, 2025

Describe the bug
Trigger element is not focused when the modal is closed and a element inside the modal got focused

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

To Reproduce
Steps to reproduce the behavior:

  1. Open any modal
  2. With tab navigate the elements of the modal or click the next slide
  3. Close the modal
  4. Tab to continue navigation
  5. Tab moves to first focusable element on the page and not the trigger

Desktop:

  • OS: Windows 11
  • Browser Chrome
  • Version 132.0.6834.112

To solve in some way the issue I'm using this code:

var lightbox = GLightbox();
  let activeElement=null;

  let modalsLinks = document.querySelectorAll('.glightbox');

  modalsLinks.forEach(link => {
      link.addEventListener('click', (event)=> {
          console.log('click');
          activeElement = document.activeElement;
      });
  })
  lightbox.on('open', (target) => {
      console.log('lightbox opened');
  });
  lightbox.on('close', (target) => {
      console.log('lightbox closed');
      activeElement.focus();
  });

@gingerchew
Copy link
Collaborator

Thanks for letting us know about this, I believe this is a known issue, but it wasn't documented in the A11y discussion thread. I've added it to the list here #433

@aloayzab88
Copy link
Author

I didn't know about that discussion and it looks like the issue about elements inside the inline lightbox not been tabbable is listed there too.

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

2 participants