Commit ae36ad6e authored by Kelvin Jiang's avatar Kelvin Jiang Committed by Chromium LUCI CQ

[Extensions a11y] Fix screen reader focusing on invisible toast text

aria-hidden=true is set on the toast when it's hidden, and removed right
before the toast is shown.

Tested manually for chrome://extensions on Mac using VoiceOver

Bug: 1084193
Change-Id: I5f11f5beec4facb52a6ab41fc34bc8b2a9d33651
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2559733Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Commit-Queue: Kelvin Jiang <kelvinjiang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832127}
parent b597d634
...@@ -38,7 +38,7 @@ Polymer({ ...@@ -38,7 +38,7 @@ Polymer({
if (this.open && this.duration !== 0) { if (this.open && this.duration !== 0) {
this.hideTimeoutId_ = window.setTimeout(() => { this.hideTimeoutId_ = window.setTimeout(() => {
this._setOpen(false); this.hide();
}, this.duration); }, this.duration);
} }
}, },
...@@ -59,6 +59,10 @@ Polymer({ ...@@ -59,6 +59,10 @@ Polymer({
// the same as a previous toast. // the same as a previous toast.
this.removeAttribute('role'); this.removeAttribute('role');
// Reset the aria-hidden attribute as screen readers need to access the
// contents of an opened toast.
this.removeAttribute('aria-hidden');
this._setOpen(true); this._setOpen(true);
this.setAttribute('role', 'alert'); this.setAttribute('role', 'alert');
...@@ -67,8 +71,12 @@ Polymer({ ...@@ -67,8 +71,12 @@ Polymer({
} }
}, },
/** Hides the toast. */ /**
* Hides the toast and ensures that screen readers cannot its contents while
* hidden.
*/
hide() { hide() {
this.setAttribute('aria-hidden', 'true');
this._setOpen(false); this._setOpen(false);
}, },
}); });
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