Specify element to focus when glightbox is closed? #371
stephenmeehanuk
started this conversation in
General
Replies: 1 comment 1 reply
-
I've had another look at the docs, I'm trying to do something like this, but it's not working... import GLightbox from "glightbox";
var lightbox = GLightbox();
lightbox.on('close', () => {
console.log(`Modal close`);
function setFocus() {
document.getElementById("glight_box").focus();
}
}); I've added The |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi
Is it possible to specify an element that gets focus when the light-box is closed?
I'm doing some accessibility testing, and I've noticed when using the keyboard I can tab to the light-box trigger, press enter to open the light-box. But when I press esc or close the light-box by clicking
gclose gbtn
the focus defaults tobody
This means keyboard users have to navigate back to the trigger button and beyond to continue navigating the website.
Is there a way to configure
glightbox
so when the light-box is closedgclose gbtn
receives focus?Hope that makes sense.
Beta Was this translation helpful? Give feedback.
All reactions