Commit d7b92ffc6f9 for woocommerce

commit d7b92ffc6f9849934476e5a5b29c067b6f650dff
Author: Tung Du <dinhtungdu@gmail.com>
Date:   Thu Nov 26 18:24:15 2026 +0700

    Hide off-screen Product Gallery slides from screen readers (#71440)

    * Hide off-screen Product Gallery slides from screen readers

    The large image viewer shows one slide at a time, but screen readers
    read every slide. Mark the slides that are not selected with
    aria-hidden, so only the image on screen is read. The thumbnails,
    arrow buttons and arrow keys still reach every image.

    Co-authored-by: Amp <amp@ampcode.com>
    Co-authored-by: Amp <amp@ampcode.com>
    Amp-Thread-ID: https://ampcode.com/threads/T-01a1f79e-44b3-77f9-8bef-3ef6cc57ac6a

    * Hide the whole off-screen Product Gallery slide

    When the gallery image links to the product, hiding only the image left
    the off-screen slides as links with no name. Set aria-hidden on the
    slide instead, so the link is hidden with its image.

    Co-authored-by: Amp <amp@ampcode.com>
    Amp-Thread-ID: https://ampcode.com/threads/T-01a1f79e-44b3-77f9-8bef-3ef6cc57ac6a

    * Drop the redundant aria-hidden on Product Gallery images

    The hidden attribute on the image or its wrapper already removes a
    filtered-out image from screen readers, so the extra aria-hidden on the
    image does nothing.

    Co-authored-by: Amp <amp@ampcode.com>
    Amp-Thread-ID: https://ampcode.com/threads/T-01a1f79e-44b3-77f9-8bef-3ef6cc57ac6a

    * Shorten the Product Gallery slide comment

    Co-authored-by: Amp <amp@ampcode.com>
    Amp-Thread-ID: https://ampcode.com/threads/T-01a1f79e-44b3-77f9-8bef-3ef6cc57ac6a

    ---------

    Co-authored-by: Amp <amp@ampcode.com>

diff --git a/plugins/woocommerce/changelog/wooplug-612-block-gallery-offscreen-images b/plugins/woocommerce/changelog/wooplug-612-block-gallery-offscreen-images
new file mode 100644
index 00000000000..8b5b35bbd33
--- /dev/null
+++ b/plugins/woocommerce/changelog/wooplug-612-block-gallery-offscreen-images
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Product Gallery block: screen readers now read only the large image on screen, not every image in the gallery.
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/product-gallery/frontend.ts b/plugins/woocommerce/client/blocks/assets/js/blocks/product-gallery/frontend.ts
index 2e0907f77e6..023012d1db2 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/product-gallery/frontend.ts
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/product-gallery/frontend.ts
@@ -269,17 +269,23 @@ const toggleImageVisibility = ( element: HTMLElement ) => {
 	}

 	const imageId = Number.parseInt( imageIdValue, 10 );
-	const { imageData } = getContext();
+	const { imageData, selectedImageId } = getContext();
 	const visibleIndex = imageData.indexOf( imageId );
 	const isVisible = visibleIndex >= 0;
 	const closestWrapper = element.closest(
 		`${ SELECTORS.largeImageWrapper }, ${ SELECTORS.thumbnail }`
 	) as HTMLElement | null;
 	const visibilityTarget = closestWrapper || element;
+	const largeImageSlide = element.closest( SELECTORS.largeImageWrapper );

 	visibilityTarget.hidden = ! isVisible;
 	visibilityTarget.style.order = isVisible ? String( visibleIndex ) : '';
-	element.setAttribute( 'aria-hidden', isVisible ? 'false' : 'true' );
+
+	// Only the slide on screen is exposed to screen readers. The thumbnails and arrows reach the rest.
+	largeImageSlide?.setAttribute(
+		'aria-hidden',
+		imageId === selectedImageId ? 'false' : 'true'
+	);
 };

 /**