Skip to content

amp-consent a11y improvement#26456

Merged
micajuine-ho merged 13 commits intoampproject:masterfrom
micajuine-ho:alert_sr
Feb 6, 2020
Merged

amp-consent a11y improvement#26456
micajuine-ho merged 13 commits intoampproject:masterfrom
micajuine-ho:alert_sr

Conversation

@micajuine-ho
Copy link
Copy Markdown
Contributor

@micajuine-ho micajuine-ho commented Jan 23, 2020

Task 2 of #26432

When the consent iframe loads (CMP and publisher), append an 'invisible' div that uses role=alertdialog attribute to trigger Screen Reader to read a consentTitle & buttonTitle (optionally provided by pubs). Clicking on button will give focus on the button that will transfer focus to the iframe.

On subsequent viewings of the consent prompt (i.e. user hits manage my consent), do not show this div again as the user has already interacted.

@micajuine-ho micajuine-ho requested review from caroqliu and removed request for lannka January 27, 2020 23:55
Copy link
Copy Markdown
Contributor

@caroqliu caroqliu left a comment

Choose a reason for hiding this comment

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

Thanks for working on this Mica!!


/** @private {string} */
this.consentTitle_ =
(config['captions'] && config['captions']['consentTitle']) ||
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Convert the first argument to a boolean here and below: !!config['captions']

titleDiv.textContent = this.consentTitle_;
button.textContent = this.buttonTitle_;
button.onclick = () => {
this.ui_ = dev().assertElement(this.ui_);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For type checking... is there a better way to do this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tryFocus(dev().assertElement(this.ui_));

@micajuine-ho micajuine-ho requested a review from caroqliu January 28, 2020 20:03

/** @private {string} */
this.buttonTitle_ =
(config['captions'] && config['captions']['buttonTitle']) ||
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Would be great to define the default message in a const string.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

buttonTitle is a bit confusing to me, it's an invisible button for screen reader only. captions kind of convey that message, but I am not sure if developer understand what to put there.
I don't have a good name in mind though. any idea?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed to consentPromptCaption_ and buttonActionCaption_, I think this is more clear.

@micajuine-ho micajuine-ho requested a review from zhouyx January 29, 2020 21:55
Copy link
Copy Markdown
Contributor

@caroqliu caroqliu left a comment

Choose a reason for hiding this comment

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

Thanks for making these changes. It looks like a number of these unit tests are testing user interaction more than individual methods. I recommend introducing end-to-end tests for some of these cases instead, though you can do that in a follow-up PR.

titleDiv.textContent = this.consentTitle_;
button.textContent = this.buttonTitle_;
button.onclick = () => {
this.ui_ = dev().assertElement(this.ui_);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tryFocus(dev().assertElement(this.ui_));

@micajuine-ho
Copy link
Copy Markdown
Contributor Author

I recommend introducing end-to-end tests for some of these cases instead, though you can do that in a follow-up PR.

Great idea, I'll add it as a task :)

@micajuine-ho micajuine-ho requested a review from caroqliu January 31, 2020 18:32
Copy link
Copy Markdown
Contributor

@caroqliu caroqliu left a comment

Choose a reason for hiding this comment

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

LGTM

@micajuine-ho micajuine-ho requested a review from zhouyx February 4, 2020 20:23
@micajuine-ho micajuine-ho requested a review from zhouyx February 5, 2020 18:12
Copy link
Copy Markdown
Contributor

@zhouyx zhouyx left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the improvement 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants