Skip to content

Commit

Permalink
[A11y] - Switching image using the Enter key
Browse files Browse the repository at this point in the history
Add the ability to switch the displayed image in the gallery by pressing the Enter key on one of the thumbnails.
  • Loading branch information
Galpittel committed Mar 14, 2024
1 parent a0dabe4 commit 9bd3bfe
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class NavigationPanel extends React.Component {
activeIndexOffsetMemory: this.activeIndexOffsetMemory,
prevActiveIndex: this.prevActiveIndex,
});
const enterKey = 'Enter';

this.prevActiveIndex = activeIndex;
this.activeIndexOffsetMemory = activeIndexOffsetMemory;
Expand Down Expand Up @@ -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' ? (
<TextItem
Expand Down

0 comments on commit 9bd3bfe

Please sign in to comment.