Improve attribution accessibility
Tab order of attribution text should be after the toggle button Add aria-expanded state to the toggle button.
This commit is contained in:
@@ -140,12 +140,18 @@ class Attribution extends Control {
|
||||
|
||||
const activeLabel =
|
||||
this.collapsible_ && !this.collapsed_ ? this.collapseLabel_ : this.label_;
|
||||
const button = document.createElement('button');
|
||||
button.setAttribute('type', 'button');
|
||||
button.title = tipLabel;
|
||||
button.appendChild(activeLabel);
|
||||
|
||||
button.addEventListener(
|
||||
/**
|
||||
* @private
|
||||
* @type {HTMLElement}
|
||||
*/
|
||||
this.toggleButton_ = document.createElement('button');
|
||||
this.toggleButton_.setAttribute('type', 'button');
|
||||
this.toggleButton_.setAttribute('aria-expanded', String(false));
|
||||
this.toggleButton_.title = tipLabel;
|
||||
this.toggleButton_.appendChild(activeLabel);
|
||||
|
||||
this.toggleButton_.addEventListener(
|
||||
EventType.CLICK,
|
||||
this.handleClick_.bind(this),
|
||||
false
|
||||
@@ -161,8 +167,8 @@ class Attribution extends Control {
|
||||
(this.collapsible_ ? '' : ' ol-uncollapsible');
|
||||
const element = this.element;
|
||||
element.className = cssClasses;
|
||||
element.appendChild(this.toggleButton_);
|
||||
element.appendChild(this.ulElement_);
|
||||
element.appendChild(button);
|
||||
|
||||
/**
|
||||
* A list of currently rendered resolutions.
|
||||
@@ -301,6 +307,7 @@ class Attribution extends Control {
|
||||
replaceNode(this.label_, this.collapseLabel_);
|
||||
}
|
||||
this.collapsed_ = !this.collapsed_;
|
||||
this.toggleButton_.setAttribute('aria-expanded', String(!this.collapsed_));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user