Skip to content

Commit

Permalink
Click on image using enter key (#1202)
Browse files Browse the repository at this point in the history
* [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.

* Using a const to store the value of the 'Enter' key

Using a const to store the value of the 'Enter' key

* Renaming ENTER_KEY const

* Renaming ENTER_KEY const
  • Loading branch information
Galpittel authored Mar 14, 2024
1 parent 1390e45 commit 81bb3ca
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { GalleryUI } from '../../item/media/GalleryUI';

import TextItem from '../../item/textItem.js';

const ENTER_KEY = 'Enter';

class NavigationPanel extends React.Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -97,7 +99,7 @@ class NavigationPanel extends React.Component {
onClick={() => this.scrollToThumbnail(idx)}
tabIndex={0}
onKeyDown={(e) => {
if (e.key === 'Enter') {
if (e.key === ENTER_KEY) {
this.scrollToThumbnail(idx);
}
}}
Expand Down

0 comments on commit 81bb3ca

Please sign in to comment.