Commit 04101b1c authored by Curt Clemens's avatar Curt Clemens Committed by Chromium LUCI CQ

[Nearby] Improve a11y on send confirmation page, discovery page

- Give error divs role=alert so that errors get announced.
- Make progress wheel accessible by setting role=progressbar and
  and providing progress via aria-valuenow. Set tabindex=0 during
  progress so that it can be focused and the percentage read.
- Add a label for the device name.
- Make the confirmation token an aria-live region so it gets read when
  it shows up.
- Hide the add contact section when the error section is visible to
  prevent overflow. (Add contact isn't implemented yet -- the elements
  are on the page, but they're never visible.)

Bug: 1148475
Change-Id: I49cbcb8c7930a3eddad042ce1ea5389306a6d067
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2569897Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarJames Vecore <vecore@google.com>
Commit-Queue: Curt Clemens <cclem@google.com>
Cr-Commit-Position: refs/heads/master@{#833745}
parent c97a89ab
<style> <style>
#addContacts { #addContacts {
margin-top: 32px; padding: 8px;
} }
#addContactsLabel { #addContactsLabel {
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<nearby-preview send-preview="[[sendPreview]]" <nearby-preview send-preview="[[sendPreview]]"
disabled="[[errorTitle_]]"> disabled="[[errorTitle_]]">
</nearby-preview> </nearby-preview>
<div id="confirmationToken"> <div id="confirmationToken" aria-live="polite">
<template is="dom-if" if="[[confirmationToken_]]"> <template is="dom-if" if="[[confirmationToken_]]">
[[i18n('nearbyShareSecureConnectionId', confirmationToken_)]] [[i18n('nearbyShareSecureConnectionId', confirmationToken_)]]
</template> </template>
...@@ -104,12 +104,13 @@ ...@@ -104,12 +104,13 @@
</div> </div>
</div> </div>
<template is="dom-if" if="[[contactName_(shareTarget)]]"> <template is="dom-if" if="[[contactName_(shareTarget, errorTitle_)]]">
<cr-checkbox id="addContacts"> <cr-checkbox id="addContacts" aria-labelledby="addContactsLabel"
<div id="addContactsLabel"> aria-describedby="addContactsLabelSecondary">
<div id="addContactsLabel" aria-hidden="true">
[[contactName_(shareTarget)]] [[contactName_(shareTarget)]]
</div> </div>
<div id="addContactsLabelSecondary"> <div id="addContactsLabelSecondary" aria-hidden="true">
[[i18n('nearbyShareConfirmationPageAddContactSubtitle')]] [[i18n('nearbyShareConfirmationPageAddContactSubtitle')]]
</div> </div>
</cr-checkbox> </cr-checkbox>
...@@ -119,9 +120,12 @@ ...@@ -119,9 +120,12 @@
<template is="dom-if" if="[[errorTitle_]]"> <template is="dom-if" if="[[errorTitle_]]">
<div id="errorSection"> <div id="errorSection">
<iron-icon id="errorIcon" icon="nearby20:info"></iron-icon> <iron-icon id="errorIcon" icon="nearby20:info"></iron-icon>
<div id="error"> <div id="error" role="alert" aria-labelledby="errorTitle"
<div id="errorTitle">[[errorTitle_]]</div> aria-describedby="errorDescription">
<div id="errorDescription">[[errorDescription_]]</div> <div id="errorTitle" aria-hidden="true">[[errorTitle_]]</div>
<div id="errorDescription" aria-hidden="true">
[[errorDescription_]]
</div>
</div> </div>
</div> </div>
</template> </template>
......
...@@ -213,7 +213,7 @@ Polymer({ ...@@ -213,7 +213,7 @@ Polymer({
contactName_() { contactName_() {
// TODO(crbug.com/1123943): Get contact name from ShareTarget. // TODO(crbug.com/1123943): Get contact name from ShareTarget.
const contactName = null; const contactName = null;
if (!contactName) { if (!contactName || this.errorTitle_) {
return ''; return '';
} }
return this.i18n('nearbyShareConfirmationPageAddContactTitle', contactName); return this.i18n('nearbyShareConfirmationPageAddContactTitle', contactName);
......
...@@ -160,9 +160,12 @@ ...@@ -160,9 +160,12 @@
<template is="dom-if" if="[[errorTitle_]]"> <template is="dom-if" if="[[errorTitle_]]">
<div id="errorSection"> <div id="errorSection">
<iron-icon id="errorIcon" icon="nearby20:info"></iron-icon> <iron-icon id="errorIcon" icon="nearby20:info"></iron-icon>
<div id="error"> <div id="error" role="alert" aria-labelledby="errorTitle"
<div id="errorTitle">[[errorTitle_]]</div> aria-describedby="errorDescription">
<div id="errorDescription">[[errorDescription_]]</div> <div id="errorTitle" aria-hidden="true">[[errorTitle_]]</div>
<div id="errorDescription" aria-hidden="true">
[[errorDescription_]]
</div>
</div> </div>
</div> </div>
</template> </template>
......
...@@ -89,7 +89,9 @@ ...@@ -89,7 +89,9 @@
} }
</style> </style>
<div id="progress-container" <div id="progress-container" role="progressbar" aria-valuemin="0"
aria-valuemax="100" aria-valuenow$="[[progress]]"
tabindex$="[[getProgressBarTabIndex_(progress)]]"
class$="[[getProgressWheelClass_(progress, hasError)]]"> class$="[[getProgressWheelClass_(progress, hasError)]]">
<!-- This svg is inlined so that it can be styled with css; otherwise, <!-- This svg is inlined so that it can be styled with css; otherwise,
it would be better to put it in an iron-icon. --> it would be better to put it in an iron-icon. -->
...@@ -101,4 +103,6 @@ ...@@ -101,4 +103,6 @@
<nearby-device-icon id="icon" share-target="[[shareTarget]]"> <nearby-device-icon id="icon" share-target="[[shareTarget]]">
</nearby-device-icon> </nearby-device-icon>
</div> </div>
<div id="device-name">[[shareTarget.name]]</div> <div id="device-name" aria-label="$i18n{nearbyShareOnboardingPageDeviceName}">
[[shareTarget.name]]
</div>
...@@ -78,4 +78,15 @@ Polymer({ ...@@ -78,4 +78,15 @@ Polymer({
this.updateStyles({'--progress-percentage': value}); this.updateStyles({'--progress-percentage': value});
} }
}, },
/**
* Allow focusing on the progress bar. Ignored by Chromevox otherwise.
* @return {number} The tabindex to be applied to the progress wheel.
*/
getProgressBarTabIndex_() {
if (this.progress && !this.hasError) {
return 0;
}
return -1;
},
}); });
...@@ -95,7 +95,7 @@ suite('ConfirmatonPageTest', function() { ...@@ -95,7 +95,7 @@ suite('ConfirmatonPageTest', function() {
}; };
const renderedName = confirmationPageElement.$$('nearby-progress') const renderedName = confirmationPageElement.$$('nearby-progress')
.$$('#device-name') .$$('#device-name')
.textContent; .innerText;
assertEquals(name, renderedName); assertEquals(name, renderedName);
}); });
......
...@@ -38,7 +38,7 @@ suite('ProgressTest', function() { ...@@ -38,7 +38,7 @@ suite('ProgressTest', function() {
}); });
progressElement.shareTarget = shareTarget; progressElement.shareTarget = shareTarget;
const renderedName = progressElement.$$('#device-name').textContent; const renderedName = progressElement.$$('#device-name').innerText;
assertEquals(name, renderedName); assertEquals(name, renderedName);
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment