@@ -108,6 +108,42 @@ const Tooltip = ({
108
108
}
109
109
}
110
110
111
+ const handleMouseMove = ( event ?: MouseEvent ) => {
112
+ if ( ! event ) {
113
+ return
114
+ }
115
+ const virtualElement = {
116
+ getBoundingClientRect ( ) {
117
+ return {
118
+ x : event . clientX ,
119
+ y : event . clientY ,
120
+ width : 0 ,
121
+ height : 0 ,
122
+ top : event . clientY ,
123
+ left : event . clientX ,
124
+ right : event . clientX ,
125
+ bottom : event . clientY ,
126
+ }
127
+ } ,
128
+ } as Element
129
+ computeTooltipPosition ( {
130
+ place,
131
+ offset,
132
+ elementReference : virtualElement ,
133
+ tooltipReference : tooltipRef . current ,
134
+ tooltipArrowReference : tooltipArrowRef . current ,
135
+ strategy : positionStrategy ,
136
+ } ) . then ( ( computedStylesData ) => {
137
+ setCalculatingPosition ( false )
138
+ if ( Object . keys ( computedStylesData . tooltipStyles ) . length ) {
139
+ setInlineStyles ( computedStylesData . tooltipStyles )
140
+ }
141
+ if ( Object . keys ( computedStylesData . tooltipArrowStyles ) . length ) {
142
+ setInlineArrowStyles ( computedStylesData . tooltipArrowStyles )
143
+ }
144
+ } )
145
+ }
146
+
111
147
// debounce handler to prevent call twice when
112
148
// mouse enter and focus events being triggered toggether
113
149
const debouncedHandleShowTooltip = debounce ( handleShowTooltip , 50 )
@@ -139,6 +175,7 @@ const Tooltip = ({
139
175
enabledEvents . push (
140
176
{ event : 'mouseenter' , listener : debouncedHandleShowTooltip } ,
141
177
{ event : 'mouseleave' , listener : debouncedHandleHideTooltip } ,
178
+ { event : 'mousemove' , listener : ( e ) => handleMouseMove ( e as MouseEvent ) } ,
142
179
{ event : 'focus' , listener : debouncedHandleShowTooltip } ,
143
180
{ event : 'blur' , listener : debouncedHandleHideTooltip } ,
144
181
)
0 commit comments