diff --git a/src/frontend/src/primitives/ToggleButton.tsx b/src/frontend/src/primitives/ToggleButton.tsx index ab844acb..8ce14e9e 100644 --- a/src/frontend/src/primitives/ToggleButton.tsx +++ b/src/frontend/src/primitives/ToggleButton.tsx @@ -1,10 +1,10 @@ +import { forwardRef, ReactNode } from 'react' import { ToggleButton as RACToggleButton, ToggleButtonProps as RACToggleButtonProps, } from 'react-aria-components' import { type ButtonRecipeProps, buttonRecipe } from './buttonRecipe' import { TooltipWrapper, TooltipWrapperProps } from './TooltipWrapper' -import { ReactNode } from 'react' export type ToggleButtonProps = RACToggleButtonProps & ButtonRecipeProps & @@ -16,24 +16,25 @@ export type ToggleButtonProps = RACToggleButtonProps & /** * React aria ToggleButton with our button styles, that can take a tooltip if needed */ -export const ToggleButton = ({ - tooltip, - tooltipType, - ...props -}: ToggleButtonProps) => { - const [variantProps, componentProps] = buttonRecipe.splitVariantProps(props) +export const ToggleButton = forwardRef( + ({ tooltip, tooltipType, ...props }, ref) => { + const [variantProps, componentProps] = buttonRecipe.splitVariantProps(props) - return ( - - - <> - {componentProps.children as ReactNode} - {props.description && {tooltip}} - - - - ) -} + return ( + + + <> + {componentProps.children as ReactNode} + {props.description && {tooltip}} + + + + ) + } +) + +ToggleButton.displayName = 'ToggleButton'