From 0f1093f208308ef4f7aade12083cb8d34e87fafc Mon Sep 17 00:00:00 2001 From: Ramon Klanke Date: Thu, 13 Apr 2023 12:59:53 +0200 Subject: [PATCH] Aria-Label not set by mapbox-gl (#2115) --- src/components/marker.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/marker.ts b/src/components/marker.ts index 95e9fcdca..a529e0c49 100644 --- a/src/components/marker.ts +++ b/src/components/marker.ts @@ -90,14 +90,26 @@ function Marker(props: MarkerProps) { const marker: MapboxMarker = useMemo(() => { let hasChildren = false; + let childElement = null; + React.Children.forEach(props.children, el => { if (el) { hasChildren = true; + + const element = el as JSX.Element; + const {children, ...other} = element.props; + + childElement = document.createElement('div'); + + if (other['aria-label']) { + childElement.setAttribute('aria-label', other['aria-label']); + } } }); + const options = { ...props, - element: hasChildren ? document.createElement('div') : null + element: childElement }; const mk = new mapLib.Marker(options).setLngLat([props.longitude, props.latitude]);