From 9bd3bfe3cd19e854d060edbca587c359921eb3a1 Mon Sep 17 00:00:00 2001 From: Galpittel Date: Thu, 14 Mar 2024 11:18:53 +0200 Subject: [PATCH] [A11y] - Switching image using the Enter key Add the ability to switch the displayed image in the gallery by pressing the Enter key on one of the thumbnails. --- .../src/components/gallery/proGallery/navigationPanel.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/gallery/src/components/gallery/proGallery/navigationPanel.js b/packages/gallery/src/components/gallery/proGallery/navigationPanel.js index d4dc8ee3ff..ca6f21e876 100644 --- a/packages/gallery/src/components/gallery/proGallery/navigationPanel.js +++ b/packages/gallery/src/components/gallery/proGallery/navigationPanel.js @@ -51,6 +51,7 @@ class NavigationPanel extends React.Component { activeIndexOffsetMemory: this.activeIndexOffsetMemory, prevActiveIndex: this.prevActiveIndex, }); + const enterKey = 'Enter'; this.prevActiveIndex = activeIndex; this.activeIndexOffsetMemory = activeIndexOffsetMemory; @@ -111,6 +112,11 @@ class NavigationPanel extends React.Component { data-key={thumbnailItem.id} style={itemStyle} onClick={() => this.scrollToThumbnail(idx)} + onKeyDown={(e) => { + if (e.key === enterKey) { + this.scrollToThumbnail(idx); + } + }} > {thumbnailItem.type === 'text' ? (