From a4640ea67ed0b7e8a5ece472123ad46d595b338b Mon Sep 17 00:00:00 2001 From: Saugat Malla Date: Thu, 27 Aug 2026 13:57:38 -0400 Subject: [PATCH 1/4] fix(issue-124) - fix the lost focus in Safari when the pressed button is disabled --- src/lib/components/gallery-nav.jsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lib/components/gallery-nav.jsx b/src/lib/components/gallery-nav.jsx index b7ee02b..d526b7d 100644 --- a/src/lib/components/gallery-nav.jsx +++ b/src/lib/components/gallery-nav.jsx @@ -12,7 +12,7 @@ export const GalleryNav = ({ children, ...props }) => { - const { next, previous, loop, activeIndex, galleryItems } = useGallery() + const { next, previous, loop, activeIndex, galleryItems, itemNodes } = useGallery() const handleClick = () => { if (direction) next() @@ -31,6 +31,17 @@ export const GalleryNav = ({ "aria-disabled": shouldDisable ? "true" : null, } + /* + * IFFE - avoiding use of useEffect + * When the clicked/pressed button gets disabled, safari resets the focus + * to the document, so we are redirecting the focus within the gallery + */ + ;(function handleLostFocus() { + if (shouldDisable) { + itemNodes.current[activeIndex]?.focus({ focusVisible: false }) + } + })() + if (!children && !renderNavItem) return null return ( From 819e5c24ca1e3ce33d2ffc2e4d4036e3dd450914 Mon Sep 17 00:00:00 2001 From: Saugat Malla Date: Thu, 27 Aug 2026 14:00:18 -0400 Subject: [PATCH 2/4] fix(issue-124) - add changeset --- .changeset/happy-days-brush.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/happy-days-brush.md diff --git a/.changeset/happy-days-brush.md b/.changeset/happy-days-brush.md new file mode 100644 index 0000000..8a2367a --- /dev/null +++ b/.changeset/happy-days-brush.md @@ -0,0 +1,5 @@ +--- +"@wethegit/react-gallery": patch +--- + +Fix the lost focus in Safari when the pressed nav button is disabled From 4e0e85067fbf21ce3bd32b9ef63a83c77d09dee2 Mon Sep 17 00:00:00 2001 From: Saugat Malla Date: Thu, 27 Aug 2026 14:24:19 -0400 Subject: [PATCH 3/4] fix(issue-124) - remove function and move it after the check --- src/lib/components/gallery-nav.jsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/lib/components/gallery-nav.jsx b/src/lib/components/gallery-nav.jsx index d526b7d..bf29ec0 100644 --- a/src/lib/components/gallery-nav.jsx +++ b/src/lib/components/gallery-nav.jsx @@ -31,18 +31,15 @@ export const GalleryNav = ({ "aria-disabled": shouldDisable ? "true" : null, } + if (!children && !renderNavItem) return null + /* - * IFFE - avoiding use of useEffect * When the clicked/pressed button gets disabled, safari resets the focus * to the document, so we are redirecting the focus within the gallery */ - ;(function handleLostFocus() { - if (shouldDisable) { - itemNodes.current[activeIndex]?.focus({ focusVisible: false }) - } - })() - - if (!children && !renderNavItem) return null + if (shouldDisable) { + itemNodes.current[activeIndex]?.focus({ focusVisible: false }) + } return (