Commit 94e8d8f9 authored by Alex Danilo's avatar Alex Danilo Committed by Commit Bot

Enhance aria-label for expand/collapse button.

Adds more detail to the aria-label for better screen reader experience
on the summary panel.

Sets the label to 'Close' when the summary panel has expanded the panel
items on display and sets it back to 'Expand' when it's collapsed.

The keywords 'Close' and 'Expand' are internationalized, the string
itself contains 'Files feedback panel' which will be internationalized
in a follow-up CL.

Bug: 989322
Change-Id: I1ae67400eed5963e7254ea644f757eed47291b01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1735448Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Commit-Queue: Alex Danilo <adanilo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#684248}
parent 19d84593
......@@ -188,9 +188,14 @@ class DisplayPanel extends HTMLElement {
const summaryPanel = panel.summary_.querySelector('xf-panel-item');
const expandButton =
summaryPanel.shadowRoot.querySelector('#primary-action');
// TODO(crbug.com/989322) i18n for this string.
const fbWindow = ' Files feedback panels';
if (panel.collapsed_) {
panel.collapsed_ = false;
expandButton.setAttribute('data-category', 'collapse');
// TODO(crbug.com/989322) create a i18n{COLLAPSE_LABEL} to replace this..
expandButton.setAttribute('aria-label', '$i18n{CLOSE_LABEL}' + fbWindow);
expandButton.setAttribute('aria-expanded', 'true');
panel.panels_.hidden = false;
panel.separator_.hidden = false;
panel.panels_.listener_ = panel.panelExpandFinished;
......@@ -199,6 +204,8 @@ class DisplayPanel extends HTMLElement {
} else {
panel.collapsed_ = true;
expandButton.setAttribute('data-category', 'expand');
expandButton.setAttribute('aria-label', '$i18n{EXPAND_LABEL}' + fbWindow);
expandButton.setAttribute('aria-expanded', 'false');
panel.separator_.hidden = true;
panel.panels_.listener_ = panel.panelCollapseFinished;
panel.panels_.addEventListener(
......
......@@ -194,11 +194,14 @@ class PanelItem extends HTMLElement {
buttonSpacer.insertAdjacentElement('afterend', secondaryButton);
break;
case this.panelTypeSummary:
// TODO(crbug.com/989322) i18n for this string.
const fbWindow = ' Files feedback panels';
this.setAttribute('indicator', 'largeprogress');
primaryButton = document.createElement('xf-button');
primaryButton.id = 'primary-action';
primaryButton.dataset.category = 'expand';
primaryButton.setAttribute('aria-label', '$i18n{EXPAND_LABEL}');
primaryButton.setAttribute(
'aria-label', '$i18n{EXPAND_LABEL}' + fbWindow);
buttonSpacer.insertAdjacentElement('afterend', primaryButton);
break;
case this.panelTypeDone:
......
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