Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[accessibility] Controls' icons should be explicitly hidden from assistive technology #12041

Closed
Malvoz opened this issue Feb 17, 2021 · 3 comments
Labels

Comments

@Malvoz
Copy link

Malvoz commented Feb 17, 2021

Screen readers currently announce the "icons" or characters inside of controls because they're not hidden from ATs.

Taking the zoom in control as an example, a screen reader such as NVDA will announce Plus button zoom in on focus, and Plus on hover.

openlayers-controls-accessible-name

Similarly, the attribution control is announced as i button attributions on focus, and i on hover, because the character "i" (for "info") is not hidden from screen readers.

I propose that these icons/characters be wrapped in a child <span aria-hidden="true"> as a child element of <button> to prevent screen readers from announcing them.

(Ideally this should also be a consideration for custom controls, if only by updating the examples.)

@Malvoz Malvoz changed the title Controls' icons should be explicitly hidden from assistive technology [accessibility] Controls' icons should be explicitly hidden from assistive technology May 13, 2021
@stale
Copy link

stale bot commented Sep 3, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added stale and removed stale labels Sep 3, 2021
@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 16, 2022
@stale stale bot closed this as completed Apr 27, 2022
@walkermatt
Copy link
Contributor

@Malvoz my understanding is that the ol/control/Zoom~Zoom zoomInLabel and zoomOutLabel properties facilitate wrapping the icons/characters in a child <span aria-hidden="true">.

The following takes a different approach of instead adding a span with a descriptive aria-label which I think results in ATs describing the zoom buttons appropriately:

import Map from 'ol/Map.js';
import OSM from 'ol/source/OSM.js';
import TileLayer from 'ol/layer/Tile.js';
import View from 'ol/View.js';
import {defaults} from 'ol/control/defaults';

// Customise the Zoom control to add a aria-label attribute to each button
const zoomInLabel = document.createElement('span');
zoomInLabel.ariaLabel = 'Zoom in';
zoomInLabel.append('+');

const zoomOutLabel = document.createElement('span');
zoomOutLabel.ariaLabel = 'Zoom out';
zoomOutLabel.append('-');

const controls = defaults({
  zoomOptions: {
    zoomInLabel: zoomInLabel,
    zoomOutLabel: zoomOutLabel
  }
});

// Create a Map instance, specifying our custom control options via
// the `controls` option
const map = new Map({
  layers: [
    new TileLayer({
      source: new OSM(),
    }),
  ],
  target: 'map',
  view: new View({
    center: [0, 0],
    zoom: 2,
  }),
  controls: controls
});

I'd welcome your thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants