-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Tooltip not working with hoverable and focusable components other than React Aria Buttons #6142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The Tooltip should work with any component using I think the tooltip not working with Tag is a different question, and may be related to how collections work. That might need more investigation. My initial thought it is that this isn't working due to |
Yeah it would be helpful to be able to wrap |
Unfortunately, Tooltips will not be added around MenuItem. For that we recommend a pattern such as https://react-spectrum.adobe.com/react-spectrum/Menu.html#unavailable-items or including a description text. Tooltips are not accessible and should not be used to convey critical information. Here are some good usage guidelines around using tooltips https://spectrum.adobe.com/page/tooltip/#Usage-guidelines |
@snowystinger any chance of adding primitives to build something like |
We have a plan to eventually add something we're referring to as "sub dialogs" as opposed to "sub menus", which is what could be used to create this more easily. I know we weren't entirely happy with the API we have in RSP right now for it. Let me check with the team and see where it is in our priorities. |
Do you mean Is there an example I can look at? |
here's where
RAC will pass some stuff on a context that that hook uses. If you're using the hooks, you'll have to handle that yourself.
useTooltipTrigger will also create onHover listeners, these should be passed through |
When I use it on a focusable component, the placement is incorrect: And when I try to repro it on codesandbox, it doesn't work: I'm using the same versions locally and in codesandbox:
|
Ah, you've just missed making a |
@snowystinger thanks, that works! A related question to const Focusable = forwardRef<HTMLSpanElement, PropsWithChildren<FocusableOptions>>((props, forwardedRef) => {
// forwardRef doesn't guarantee a ref, so need to create a backup one so that we have a ref to our trigger every time
const backupRef = useRef(null)
const ref = forwardedRef ?? backupRef
// Argument of type '((instance: HTMLSpanElement | null) => void) | MutableRefObject<HTMLSpanElement | null>' is not assignable to parameter of type 'RefObject<FocusableElement>'.
// Type '(instance: HTMLSpanElement | null) => void' is not assignable to type 'RefObject<FocusableElement>'
const { focusableProps } = useFocusable(props, ref)
return <span {...props} {...focusableProps} ref={ref} />
}) In |
|
Is here any specific reason that
|
I think we've solved this one as of the next release.
|
Uh oh!
There was an error while loading. Please reload this page.
Provide a general summary of the issue here
We are trying to use the Tooltip to create Tags that, when hovered, show a message.
Specifically, we have Tags (TagGroup) with some text and a Remove Button.
If we remove the Button from the Tag, the Tooltip never appears, even if it's a controlled open state. This makes it impossible to use Tooltips with components that are not buttons. And specifically, react-aria-components Buttons. It doesn't work with pure HTML buttons.
Additionally, we want to place the Tooltip on top of the Tag, pointing to the exact center of the tag. However, the Tooltip is placed in reference to the Remove button of the tag instead. We can reposition it using the triggerRef, but we wonder if it's because of the first behavior that this happens.
We would appreciate any help :)
Thank you.
P.S: We are aware that interactions on hover aren't very recommended, but it's required in our use case.
🤔 Expected Behavior?
The tooltip should be usable with any component that is hoverable and focusable, and it should be placed using the whole content of the Tooltip as a reference.
😯 Current Behavior
The tooltip should does not work with any component that is hoverable and focusable, other than React Aria Button, and it is placed using the first Button inside the tooltip as a reference.
💁 Possible Solution
No response
🔦 Context
We want the Tooltip to be usable with any hoverable and focusable component, like Tags, Buttons (our own buttons), etc.
🖥️ Steps to Reproduce
Version
react-aria-components 1.1.1
What browsers are you seeing the problem on?
Chrome
If other, please specify.
No response
What operating system are you using?
MacOS
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response
The text was updated successfully, but these errors were encountered: