You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're using react-aria-components, and are pretty happy with everything so far, but we have hit a bit of a challenge with RadioGroup and Tooltip.
We have a use-case for a group of buttons where the buttons act as a radio group, to select between different settings. Usually we would just use the icon variant, and have information about what the option does show as a tooltip:
This is for a web application that'll only be used on desktops, not mobile.
The existing react-aria-components Radio does not support tooltips as the focusableProps are put onto a VisuallyHidden input component:
We've managed to hack in support for tooltips doing something like below (not functioning code, if necessary I can create a codesandbox):
interfaceCustomRadioPropsextendsAriaRadioProps{children: string;icon: React.FC<React.SVGProps<SVGSVGElement>>;}functionCustomRadio(props: CustomRadioProps,ref: React.ForwardedRef<HTMLLabelElement>,){const{ children,icon: Icon, ...radioProps}=props;constinnerRef=React.useRef<HTMLDivElement>(null);const{ focusableProps }=useFocusable({},innerRef);return(<divclassName={radioButton}ref={innerRef}{...focusableProps}><AriaRadioclassName={({ isDisabled })=>button({ isDisabled })}ref={ref}aria-label={children}{...radioProps}><IconclassName={iconStyle({size: "s"})}/></AriaRadio></div>);}functionExample(){return(<AriaRadioGroup><TooltipTrigger><AriaTooltip>Hello World</AriaTooltip><CustomRadioicon={Circle}value="a">
First
</CustomRadio></TooltipTrigger><TooltipTrigger><AriaTooltip>Hello World</AriaTooltip><CustomRadioicon={Circle}value="b">
Second
</CustomRadio></TooltipTrigger><TooltipTrigger><AriaTooltip>Hello World</AriaTooltip><CustomRadioicon={Circle}value="c">
Third
</CustomRadio></TooltipTrigger></AriaRadioGroup>);}
The issue with this is that if you click on the button while the tooltip animation is playing then it gets re-positioned to the visually hidden input element, so it looks weird:
If the animation completes (we just use the default animation for RAC tooltips) then everything works fine.
So my question is:
Is the lack of support for tooltips in RadioGroup / Radio on purpose, or is it just that no one has needed that feature yet?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello!
We're using react-aria-components, and are pretty happy with everything so far, but we have hit a bit of a challenge with RadioGroup and Tooltip.
We have a use-case for a group of buttons where the buttons act as a radio group, to select between different settings. Usually we would just use the icon variant, and have information about what the option does show as a tooltip:
This is for a web application that'll only be used on desktops, not mobile.
The existing react-aria-components Radio does not support tooltips as the focusableProps are put onto a VisuallyHidden input component:
react-spectrum/packages/react-aria-components/src/RadioGroup.tsx
Lines 227 to 229 in 4baa1b0
We've managed to hack in support for tooltips doing something like below (not functioning code, if necessary I can create a codesandbox):
The issue with this is that if you click on the button while the tooltip animation is playing then it gets re-positioned to the visually hidden input element, so it looks weird:
If the animation completes (we just use the default animation for RAC tooltips) then everything works fine.
So my question is:
Beta Was this translation helpful? Give feedback.
All reactions