Accessibility fixes

- Aria landmarks
 - Title attributes to all icon only buttons
 - <Multibutton/> now internally a radio group
 - Replaced 1 'skip navigation link' with UI group links
 - Added map specific shortcuts to the shortcut menu
 - Hidden layer list actions from tab index
This commit is contained in:
orangemug
2020-05-18 19:37:49 +01:00
parent e3e6647e03
commit b28407a4a0
25 changed files with 260 additions and 74 deletions

View File

@@ -289,7 +289,9 @@ export default class LayerEditor extends React.Component {
}
return <div className="maputnik-layer-editor"
>
role="main"
aria-label="Layer editor"
>
<header>
<div className="layer-header">
<h2 className="layer-header__title">
@@ -301,7 +303,7 @@ export default class LayerEditor extends React.Component {
onSelection={handleSelection}
closeOnSelection={false}
>
<Button className='more-menu__button'>
<Button id="skip-target-layer-editor" className='more-menu__button' title="Layer options">
<MdMoreVert className="more-menu__button__svg" />
</Button>
<Menu>

View File

@@ -91,9 +91,18 @@ class LayerListContainer extends React.Component {
groupedLayers() {
const groups = []
const layerIdCount = new Map();
for (let i = 0; i < this.props.layers.length; i++) {
const origLayer = this.props.layers[i];
const previousLayer = this.props.layers[i-1]
const layer = this.props.layers[i]
layerIdCount.set(origLayer.id,
layerIdCount.has(origLayer.id) ? layerIdCount.get(origLayer.id) + 1 : 0
);
const layer = {
...origLayer,
key: `layers-list-${origLayer.id}-${layerIdCount.get(origLayer.id)}`,
}
if(previousLayer && layerPrefix(previousLayer.id) == layerPrefix(layer.id)) {
const lastGroup = groups[groups.length - 1]
lastGroup.push(layer)
@@ -191,14 +200,13 @@ class LayerListContainer extends React.Component {
const listItems = []
let idx = 0
const layerIdCount = new Map();
const layersByGroup = this.groupedLayers();
layersByGroup.forEach(layers => {
const groupPrefix = layerPrefix(layers[0].id)
if(layers.length > 1) {
const grp = <LayerListGroup
data-wd-key={[groupPrefix, idx].join('-')}
aria-controls={layers.map(l => l.key).join(" ")}
key={`group-${groupPrefix}-${idx}`}
title={groupPrefix}
isActive={!this.isCollapsed(groupPrefix, idx) || idx === this.props.selectedLayerIndex}
@@ -223,10 +231,6 @@ class LayerListContainer extends React.Component {
additionalProps.ref = this.selectedItemRef;
}
layerIdCount.set(layer.id,
layerIdCount.has(layer.id) ? layerIdCount.get(layer.id) + 1 : 0
);
const key = `${layer.id}-${layerIdCount.get(layer.id)}`;
const listItem = <LayerListItem
className={classnames({
'maputnik-layer-list-item-collapsed': layers.length > 1 && this.isCollapsed(groupPrefix, groupIdx) && idx !== this.props.selectedLayerIndex,
@@ -234,7 +238,7 @@ class LayerListContainer extends React.Component {
'maputnik-layer-list-item--error': !!layerError
})}
index={idx}
key={key}
key={layer.key}
layerId={layer.id}
layerIndex={idx}
layerType={layer.type}
@@ -251,7 +255,12 @@ class LayerListContainer extends React.Component {
})
})
return <div className="maputnik-layer-list" ref={this.scrollContainerRef}>
return <div
className="maputnik-layer-list"
role="complementary"
aria-label="Layers list"
ref={this.scrollContainerRef}
>
<AddModal
layers={this.props.layers}
sources={this.props.sources}
@@ -265,7 +274,7 @@ class LayerListContainer extends React.Component {
<div className="maputnik-default-property">
<div className="maputnik-multibutton">
<button
id="skip-menu"
id="skip-target-layer-list"
onClick={this.toggleLayers}
className="maputnik-button">
{this.state.areAllGroupsExpanded === true ? "Collapse" : "Expand"}
@@ -283,7 +292,10 @@ class LayerListContainer extends React.Component {
</div>
</div>
</header>
<ul className="maputnik-layer-list-container">
<ul className="maputnik-layer-list-container"
role="navigation"
aria-label="Layers list"
>
{listItems}
</ul>
</div>

View File

@@ -16,7 +16,13 @@ export default class LayerListGroup extends React.Component {
data-wd-key={"layer-list-group:"+this.props["data-wd-key"]}
onClick={e => this.props.onActiveToggle(!this.props.isActive)}
>
<span className="maputnik-layer-list-group-title">{this.props.title}</span>
<button
className="maputnik-layer-list-group-title"
aria-controls={this.props['aria-controls']}
aria-expanded={this.props.isActive}
>
{this.props.title}
</button>
<span className="maputnik-space" />
<Collapser
style={{ height: 14, width: 14 }}

View File

@@ -14,7 +14,9 @@ const DraggableLabel = SortableHandle((props) => {
className="layer-handle__icon"
type={props.layerType}
/>
<span className="maputnik-layer-list-item-id">{props.layerId}</span>
<button className="maputnik-layer-list-item-id">
{props.layerId}
</button>
</div>
});
@@ -54,6 +56,7 @@ class IconAction extends React.Component {
className={`maputnik-layer-list-icon-action ${classAdditions}`}
data-wd-key={this.props.wdKey}
onClick={this.props.onClick}
aria-hidden="true"
>
{this.renderIcon()}
</button>