From 9244f4474c713b1f32d4ca99eb3d4373ab017e90 Mon Sep 17 00:00:00 2001 From: Sabrina Bongiovanni Date: Fri, 6 Oct 2023 17:34:55 +0200 Subject: [PATCH] feat: added aria tags for SR accessibility --- src/components/OSMMap/OSMMap.jsx | 38 +++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/components/OSMMap/OSMMap.jsx b/src/components/OSMMap/OSMMap.jsx index 438b5c9..5ab91c6 100644 --- a/src/components/OSMMap/OSMMap.jsx +++ b/src/components/OSMMap/OSMMap.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { defineMessages } from 'react-intl'; +import { defineMessages, useIntl } from 'react-intl'; import PropTypes from 'prop-types'; import L from 'leaflet'; import { Map, TileLayer, Marker, Tooltip, Popup } from 'react-leaflet'; @@ -15,12 +15,14 @@ import 'volto-venue/components/OSMMap/OSMMap.css'; // eslint-disable-next-line import/no-unresolved import 'volto-venue/components/OSMMap/leaflet.css'; -const messages = defineMessages({ - attribution: { - id: '&copy OpenStreetMap contributors', - defaultMessage: '&copy OpenStreetMap contributors', - }, -}); +// const messages = defineMessages({ +// attribution: { +// id: +// '&copy OpenStreetMap contributors', +// defaultMessage: +// '&copy OpenStreetMap contributors', +// }, +// }); let DefaultIcon = L.icon({ iconUrl: icon, @@ -43,6 +45,7 @@ const OSMMap = ({ cluster = false, mapOptions = {}, }) => { + // const intl = useIntl(); const bounds = L.latLngBounds( markers.map((marker) => [marker.latitude, marker.longitude]), ); @@ -56,15 +59,30 @@ const OSMMap = ({ draggable={draggable} onDragend={onMarkerDragEnd} onClick={position.onMarkerClick} + onKeyDown={(event) => { + if (event.originalEvent.key === 'Enter') { + position.onMarkerClick(); + } + }} icon={position.divIcon ? L.divIcon(position.divIcon) : DefaultIcon} + aria-label={position.title} + title={position.title} > {showTooltip && position.title && ( - + {position.title} )} {showPopup && position.popupContent && ( - + {position.popupContent} )} @@ -83,7 +101,7 @@ const OSMMap = ({ {...mapOptions} > {cluster ? (