react-img-mapper icon indicating copy to clipboard operation
react-img-mapper copied to clipboard

Accessibility Improvements – Dynamic Alt Text

Open sheepysheepy opened this issue 1 year ago • 1 comments

Map is getting flagged for accessibility issues – namely around labelling for the map and individual area elements.

https://www.w3.org/WAI/tutorials/images/imagemap/

For image maps, text alternatives are needed on both the element itself (to convey the informative context) and on each of the elements (to convey the link destination or the action that will be initiated if the link is followed).

Currently, the img element and all area elements are hardcoded with the alt text "map". I'd like to be able to pass in more descriptive alt text for each.

Is it possible to add this functionality?

sheepysheepy avatar Feb 16 '24 20:02 sheepysheepy

Not right now, but will be in the new version

NishargShah avatar Feb 17 '24 09:02 NishargShah

Resolved in V2.0.0-alpha.8 release, please check imgProps/areaProps

NishargShah avatar Jan 26 '25 16:01 NishargShah

I'm unable to see how the alt text can be edited - currently I'm still seeing alt="map" hardcoded in the source code. Could you give me further instruction? Thank you!

sheepysheepy avatar Feb 10 '25 17:02 sheepysheepy

You can see imgProps is spread in the code, so alt will be replaced by the code if you will add that in the imgProps

https://github.com/img-mapper/react-img-mapper/blob/master/src/ImageMapper.tsx#L303

NishargShah avatar Feb 10 '25 17:02 NishargShah

Appreciate the response! That works great for setting a custom img alt, but I'm still unable to assign alt text to each area - ideally this would be set per area in the same way that I can set coords or ids. It looks like I can only pass a single alt text string via areaProps that is used across all areas - is there another approach?

sheepysheepy avatar Feb 11 '25 11:02 sheepysheepy