#9898·Leaflet

Interactive markers are not operable with a keyboard [2.0] [Accessibility] - with PR

Author: nfreearCreated Sep 19, 2025Updated Sep 23, 2026
Labelsaccessibility

Checklist

  • I've looked at the documentation to make sure the behavior isn't documented and expected.
  • I'm sure this is an issue with Leaflet, not with my app or other dependencies (Angular, Cordova, React, etc.).
  • I've searched through the current issues to make sure this hasn't been reported yet.
  • I agree to follow the Code of Conduct that this project adheres to.

Steps to reproduce

  1. Observe an interactive marker element, within a Leaflet map.
  2. Navigate onto it with a keyboard using Tab.
  3. Attempt to activate the element with Return or Space.
  4. Observe that the element does not respond.
  5. Observe that there is not an alternative way to access the same information or functionality.

Expected behavior

I expect to be able to open an alert() popup, or other popup from an interactive marker in a Leaflet map, using just the keyboard - with the Tab, Shift+Tab, Return/Enter and Space keys (Keyboard testing).

javascript
const marker = new Marker([51.5, -0.09])
  .on('click', (ev) => alert('Marker click!'))
  .addTo(map);

Current behavior

At present, I'm forced to use a mouse.

For those who rely on a keyboard this is a blocking accessibility bug.


Cause

The root cause of this is that the marker element is an <img> element, which is non-interactive by default. As such, Return and Space key presses do not result in click events.

(Note that ARIA and role attributes have no bearing on keyboard accessibility.)

Fix

A fix is to replace the <img> element with a native interactive element, such as <button>, <input> or <a href="..">. With these, Return and/or Space key presses do result in click events.

A neat fix would be to use an <input> element with a type="image" attribute. This would result in:

Interactive marker:

xml
<input type="image" src="marker.png" alt="Interactive marker" ...>

Non-interactive markers (keyboard: false in options):

xml
<img src="marker.png" alt="Static marker" ...>

Minimal example reproducing the issue

Environment

  • Leaflet version: 2.0.0-alpha.1,
  • Browser: Chrome 140.0
  • OS/Platform: Mac OS 10.15.7

(Note, the bug will be the same on any desktop browser/OS combination.)