@@ -15,6 +15,7 @@ import { hasValidCoordinates } from "../lib/mapUtils";
1515
1616type MapPinLayerProps = {
1717 listings : ListingMarker [ ] ;
18+ markerLabel : string ;
1819 selectedListingId : number | null ;
1920 onMarkerClick : ( listing : ListingMarker ) => void ;
2021} ;
@@ -23,6 +24,7 @@ type ListingMapPinMarkerProps = {
2324 listing : ListingMarker ;
2425 coords : ListingCoordinates ;
2526 isSelected : boolean ;
27+ markerLabel : string ;
2628 onMarkerClick : MapPinLayerProps [ "onMarkerClick" ] ;
2729} ;
2830
@@ -36,6 +38,7 @@ function ListingMapPinMarker({
3638 listing,
3739 coords,
3840 isSelected,
41+ markerLabel,
3942 onMarkerClick,
4043} : ListingMapPinMarkerProps ) {
4144 const markerRef = useRef < MarkerInstance | null > ( null ) ;
@@ -51,6 +54,8 @@ function ListingMapPinMarker({
5154 if ( ! markerElement ) return ;
5255
5356 markerElement . tabIndex = 0 ;
57+ markerElement . setAttribute ( "role" , "button" ) ;
58+ markerElement . setAttribute ( "aria-label" , markerLabel ) ;
5459
5560 const activateFromKeyboard = ( event : KeyboardEvent ) => {
5661 lastKeyboardActivationRef . current = event . timeStamp ;
@@ -86,10 +91,13 @@ function ListingMapPinMarker({
8691
8792 return ( ) => {
8893 isSpaceActivationPendingRef . current = false ;
94+ markerElement . removeAttribute ( "aria-label" ) ;
95+ markerElement . removeAttribute ( "role" ) ;
96+ markerElement . removeAttribute ( "tabindex" ) ;
8997 markerElement . removeEventListener ( "keydown" , handleMarkerKeyDown ) ;
9098 markerElement . removeEventListener ( "keyup" , handleMarkerKeyUp ) ;
9199 } ;
92- } , [ listing , onMarkerClick ] ) ;
100+ } , [ listing , markerLabel , onMarkerClick ] ) ;
93101
94102 const handlePinClick = ( event : ReactMouseEvent < HTMLDivElement > ) => {
95103 event . preventDefault ( ) ;
@@ -146,6 +154,7 @@ function ListingMapPinMarker({
146154
147155export default function MapPinLayer ( {
148156 listings,
157+ markerLabel,
149158 selectedListingId,
150159 onMarkerClick,
151160} : MapPinLayerProps ) {
@@ -163,6 +172,7 @@ export default function MapPinLayer({
163172 listing = { listing }
164173 coords = { coords }
165174 isSelected = { isSelected }
175+ markerLabel = { markerLabel }
166176 onMarkerClick = { onMarkerClick }
167177 />
168178 ) ;
0 commit comments