File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,17 @@ export default {
5151 'Whether to make the tooltip interactive - if set to true, the tooltip contents will receive pointer events' ,
5252 defaultValue : false ,
5353 } ,
54+ activateOnHover : {
55+ control : 'boolean' ,
56+ description : 'Whether to activate the tooltip on mouse hover' ,
57+ defaultValue : true ,
58+ } ,
59+ activateOnClick : {
60+ control : 'boolean' ,
61+ description :
62+ 'Whether to activate the tooltip on mouse click - repeated clicks will toggle the tooltip' ,
63+ defaultValue : false ,
64+ } ,
5465 } ,
5566} as Meta < typeof Tooltip >
5667
Original file line number Diff line number Diff line change 88 offset ,
99 safePolygon ,
1010 shift ,
11+ useClick ,
1112 useFloating ,
1213 useHover ,
1314 useInteractions ,
@@ -68,6 +69,8 @@ export type TooltipProps = {
6869 keepOpen ?: boolean
6970 place ?: TooltipPlacement
7071 interactive ?: boolean
72+ activateOnHover ?: boolean
73+ activateOnClick ?: boolean
7174} & (
7275 | {
7376 noDefaultStyles : false
@@ -123,6 +126,8 @@ export const Tooltip: React.FC<TooltipProps> = (props) => {
123126 keepOpen = false ,
124127 place,
125128 interactive = false ,
129+ activateOnHover = true ,
130+ activateOnClick = false ,
126131 ...cardProps
127132 } = props
128133 const [ isOpen , setIsOpen ] = useState ( false )
@@ -157,12 +162,16 @@ export const Tooltip: React.FC<TooltipProps> = (props) => {
157162
158163 const { getReferenceProps, getFloatingProps } = useInteractions ( [
159164 useHover ( context , {
165+ enabled : activateOnHover ,
160166 delay : 200 ,
161167 move : true ,
162168 handleClose : safePolygon ( {
163169 buffer : 1 ,
164170 } ) ,
165171 } ) ,
172+ useClick ( context , {
173+ enabled : activateOnClick ,
174+ } ) ,
166175 ] )
167176
168177 const RenderComponent = noBackground ? motion . div : TooltipContainer
You can’t perform that action at this time.
0 commit comments