From eb58df540ece6374211b6fd8641430cbf2e9bbe9 Mon Sep 17 00:00:00 2001
From: Olivia206 <olivia.simonet206@gmail.com>
Date: Wed, 21 Feb 2024 15:08:30 +0100
Subject: [PATCH] fixed a11y for lightbox modal

---
 assets/js/vendors/lightbox.js | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/assets/js/vendors/lightbox.js b/assets/js/vendors/lightbox.js
index b2cb7617..dd58b5fb 100644
--- a/assets/js/vendors/lightbox.js
+++ b/assets/js/vendors/lightbox.js
@@ -1,6 +1,24 @@
 import gLightbox from 'glightbox';
 
-gLightbox({
+let lightboxBtn;
+
+const lightbox = gLightbox({
     openEffect: 'fade',
-    closeEffect: 'fade'
+    closeEffect: 'fade',
+    onOpen: () => {
+        lightboxBtn = document.activeElement;
+    },
+    onClose: () => {
+        if (lightboxBtn) {
+            lightboxBtn.focus();
+        }
+    }
 });
+
+lightbox.on('slide_changed', () => {
+    const currentSlide = document.querySelector('.gslide.current');
+    if (currentSlide) {
+        currentSlide.setAttribute("tabindex", "0");
+        currentSlide.focus();
+    }
+});
\ No newline at end of file
-- 
GitLab