Skip to content

Commit

Permalink
fix(rac): Add a comment to explain Tooltip Button
Browse files Browse the repository at this point in the history
Change-Id: Ie54763289817a7c5734e12f65ea8905bbeb5ec4b
GitOrigin-RevId: 9d43875f630bfe4ce964f5aa781abbdd693bd7e9
  • Loading branch information
sarahsga authored and actions-user committed Oct 29, 2024
1 parent b6dad1c commit e329708
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions plasmicpkgs/react-aria/src/registerTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ export interface BaseTooltipProps
const { variants, withObservedValues } =
pickAriaComponentVariants(TOOLTIP_VARIANTS);

/*
React Aria's TooltipTrigger only allows Aria Button component to act as a trigger.
https://react-spectrum.adobe.com/react-aria/Tooltip.html#example
To bypass that limitation, we use useButton,
so that anything we add to the slot can be treated as an Aria Button.
That means we can use the ready-made components provided by react-aria-components (like <TooltipTrigger> and <Tooltip>)
and still be able to use any other component as a trigger.
*/

function TooltipButton(props: AriaButtonProps) {
const ref = React.useRef<HTMLButtonElement | null>(null);
const { buttonProps } = useButton(props, ref);
Expand Down

0 comments on commit e329708

Please sign in to comment.