adobe / react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
https://react-spectrum.adobe.com
Apache License 2.0
12.63k stars 1.09k forks source link

Title Prop Does not end up on Action Button #3978

Closed joepuzzo closed 1 year ago

joepuzzo commented 1 year ago

🐛 Bug Report

In the below case the title prop will not end up on the button.

 <ActionButton
          title="Do Something"
          aria-label="Do Something"
          onPress={() => doSomething()}
        >

This is using the latest version 3.24.1

snowystinger commented 1 year ago

I don't see that as a prop we support for ActionButtons https://react-spectrum.adobe.com/react-spectrum/ActionButton.html#props where are you getting that it should? Or why do you need it?

joepuzzo commented 1 year ago

Action button is a button. Therefore it should allow any native DOM prop ( title being one of them )

If you dont support this then you will never be able to hover over an icon button and see what it does. ( as an example )

snowystinger commented 1 year ago

That's what TooltipTrigger is for https://react-spectrum.adobe.com/react-spectrum/Tooltip.html

This covers a few problems that native titles have. One, a keyboard user will never see it https://jsfiddle.net/a6zk7jce/. And two, VoiceOver frequently doesn't read titles.

Neither of them addresses touch users, though, so it's still recommended not to use tooltips. It's better to use ContextualHelp https://react-spectrum.adobe.com/react-spectrum/ContextualHelp.html where it makes sense.

You can also use an aria-label (which VO will read) or use an internationalized label and not rely on an icon alone.

joepuzzo commented 1 year ago

Ahh ok I will use tooltip then thanks!

joepuzzo commented 1 year ago

PS. Would be super cool if I could open a tooltip on an Alert Icon ( Or any Icon ) without it also having to be a button.

snowystinger commented 1 year ago

PS. Would be super cool if I could open a tooltip on an Alert Icon ( Or any Icon ) without it also having to be a button.

This is also intentional. The target must be focusable so that keyboard navigation can reach it. We are working to expand the definition of focusable, but it wouldn't be expanded to just an Icon.

joepuzzo commented 1 year ago

Ok cool thanks so much for your help!