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

Add amp-image-lightbox screen reader close button #5894

Merged
merged 1 commit into from
Oct 31, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions extensions/amp-image-lightbox/0.1/amp-image-lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,19 @@ class AmpImageLightbox extends AMP.BaseElement {
this.captionElement_.classList.add('-amp-image-lightbox-caption');
this.container_.appendChild(this.captionElement_);

// Invisible close button at the end of lightbox for screen-readers.
const screenReaderCloseButton = this.element.ownerDocument
.createElement('button');
// TODO(aghassemi, #4146) i18n
screenReaderCloseButton.textContent = 'Close the lightbox';
screenReaderCloseButton.classList.add('-amp-screen-reader');
// This is for screen-readers only, should not get a tab stop.
screenReaderCloseButton.tabIndex = -1;
screenReaderCloseButton.addEventListener('click', () => {
this.close();
});
this.element.appendChild(screenReaderCloseButton);

const gestures = Gestures.get(this.element);
this.element.addEventListener('click', e => {
if (!this.entering_ &&
Expand Down