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

fix(ThumbnailsSidebar): A11Y - add aria-current to ThumbnailsSidebar #1417

Merged
Merged
3 changes: 3 additions & 0 deletions src/lib/ThumbnailsSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ class ThumbnailsSidebar {

if (pageNum === this.currentPage) {
thumbnailEl.classList.add(CLASS_BOX_PREVIEW_THUMBNAIL_IS_SELECTED);
thumbnailEl.setAttribute('aria-current', true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this value get updated as the user changes between pages?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jstoffan you are right. I added and removed the aria-current when user changes between pages.

}

// If image is already in cache, then use it instead of waiting for
Expand Down Expand Up @@ -439,8 +440,10 @@ class ThumbnailsSidebar {
const parsedPageNum = parseInt(thumbnailEl.dataset.bpPageNum, 10);
if (parsedPageNum === this.currentPage) {
thumbnailEl.classList.add(CLASS_BOX_PREVIEW_THUMBNAIL_IS_SELECTED);
thumbnailEl.setAttribute('aria-current', true);
} else {
thumbnailEl.classList.remove(CLASS_BOX_PREVIEW_THUMBNAIL_IS_SELECTED);
thumbnailEl.removeAttribute('aria-current');
}
});
}
Expand Down