Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A11Y - Load more button accessible fix #1337

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/gallery/src/components/gallery/proGallery/galleryView.js
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ class GalleryView extends React.Component {
super(props);
this.handleKeys = this.handleKeys.bind(this);
this.showMoreItems = this.showMoreItems.bind(this);
this.onLoadMoreButtonKeyDown = this.onLoadMoreButtonKeyDown.bind(this);
this.onLoadMoreButtonKeyUp = this.onLoadMoreButtonKeyUp.bind(this);
this.createGalleryConfig = this.createGalleryConfig.bind(this);
this.screenLogs = this.screenLogs.bind(this);
this.createGallery = this.createGallery.bind(this);
@@ -128,6 +130,30 @@ class GalleryView extends React.Component {
}
}

onLoadMoreButtonKeyDown(e) {
switch (e.keyCode || e.charCode) {
case 32: // space
case 13: // enter
e.preventDefault();
e.stopPropagation();
this.props.actions.toggleLoadMoreItems();
return false;
default:
break;
}
}

onLoadMoreButtonKeyUp(e) {
switch (e.keyCode || e.charCode) {
case 32: // space
case 13: // enter
e.stopPropagation();
return false;
default:
break;
}
}

createGallery(showMore) {
const {
options,
@@ -289,6 +315,8 @@ class GalleryView extends React.Component {
onMouseDown={(e) => e.preventDefault()}
data-hook="show-more"
aria-label={buttonText}
onKeyDown={this.onLoadMoreButtonKeyDown}
onKeyUp={this.onLoadMoreButtonKeyUp}
>
{buttonText}
</button>

Unchanged files with check annotations Beta

Check warning on line 10 in packages/gallery/src/components/gallery/index.tsx

GitHub Actions / lint (16.20.0)

Unexpected any. Specify a different type

Check warning on line 11 in packages/gallery/src/components/gallery/index.tsx

GitHub Actions / lint (16.20.0)

Unexpected any. Specify a different type

Check warning on line 4 in packages/gallery/src/components/helpers/emitter.ts

GitHub Actions / lint (16.20.0)

Unexpected any. Specify a different type

Check warning on line 10 in packages/gallery/src/components/helpers/emitter.ts

GitHub Actions / lint (16.20.0)

Missing return type on function

Check warning on line 12 in packages/gallery/src/components/helpers/emitter.ts

GitHub Actions / lint (16.20.0)

Forbidden non-null assertion

Check warning on line 34 in packages/gallery/src/components/helpers/emitter.ts

GitHub Actions / lint (16.20.0)

Missing return type on function

Check warning on line 44 in packages/gallery/src/components/helpers/emitter.ts

GitHub Actions / lint (16.20.0)

Missing return type on function

Check warning on line 1 in packages/gallery/src/components/helpers/proxy.ts

GitHub Actions / lint (16.20.0)

Unexpected any. Specify a different type

Check warning on line 34 in packages/gallery/src/components/helpers/thumbnailsLogic.ts

GitHub Actions / lint (16.20.0)

Unexpected any. Specify a different type

Check warning on line 34 in packages/gallery/src/components/helpers/thumbnailsLogic.ts

GitHub Actions / lint (16.20.0)

Unexpected any. Specify a different type