nfreear / leaflet.plugins

A collection of accessibility and localisation/ translation plugins for Leaflet.js
https://nfreear.github.io/leaflet.plugins/
MIT License
5 stars 0 forks source link

Map container needs an accessible name and role #2

Open nfreear opened 1 year ago

nfreear commented 1 year ago

Problem

Leaflet's map container element is focusable because it has a tabindex="0" attribute set. This enables keyboard users to, "... navigate the map with keyboard arrows and +/- keys."

Every interactive element should have an accessible name, role and value (and/or state). Without an accessible name and role, users of assistive technology will not understand what they can do when focused on the map container.

Solution

Set role and aria-label attributes on the container element. We can also set aria-roledescription (note, this needs translating/localizing, as does aria-label). For example:

mapElem.role = 'region';
mapElem.ariaLabel = _('Map');
mapElem.ariaRoleDescription = _('map');

Result:

<div
  class="leaflet-container ..."
  tabindex="0"
  role="region"
  aria-label="Map"
  aria-roledescription="map"
  >
  ...
</div>

nfreear commented 1 year ago

Potentially make role configurable, or dependent on logic (for example, is container interactive?)