1
- import type { TriggerProps } from '@rc-component/trigger' ;
1
+ import type { TriggerProps , TriggerRef } from '@rc-component/trigger' ;
2
2
import Trigger from '@rc-component/trigger' ;
3
3
import type { ActionType , AlignType , AnimationType } from '@rc-component/trigger/lib/interface' ;
4
4
import * as React from 'react' ;
@@ -37,7 +37,11 @@ export interface TooltipProps extends Pick<TriggerProps, 'onPopupAlign' | 'built
37
37
zIndex ?: number ;
38
38
}
39
39
40
- const Tooltip = ( props : TooltipProps , ref ) => {
40
+ export interface TooltipRef {
41
+ forceAlign : VoidFunction ;
42
+ }
43
+
44
+ const Tooltip = ( props : TooltipProps , ref : React . Ref < TooltipRef > ) => {
41
45
const {
42
46
overlayClassName,
43
47
trigger = [ 'hover' ] ,
@@ -64,8 +68,8 @@ const Tooltip = (props: TooltipProps, ref) => {
64
68
...restProps
65
69
} = props ;
66
70
67
- const domRef = useRef ( null ) ;
68
- useImperativeHandle ( ref , ( ) => domRef . current ) ;
71
+ const triggerRef = useRef < TriggerRef > ( null ) ;
72
+ useImperativeHandle ( ref , ( ) => triggerRef . current ) ;
69
73
70
74
const extraProps = { ...restProps } ;
71
75
if ( 'visible' in props ) {
@@ -86,7 +90,7 @@ const Tooltip = (props: TooltipProps, ref) => {
86
90
action = { trigger }
87
91
builtinPlacements = { placements }
88
92
popupPlacement = { placement }
89
- ref = { domRef }
93
+ ref = { triggerRef }
90
94
popupAlign = { align }
91
95
getPopupContainer = { getTooltipContainer }
92
96
onPopupVisibleChange = { onVisibleChange }
0 commit comments