@@ -67,9 +67,10 @@ function computeHorizontalShift(windowWidth, xOffset, componentWidth, tooltipWid
67
67
* and the top edge of the wrapped component.
68
68
* @param {Element } [tooltip] - The reference to the tooltip's root element
69
69
* @param {Number } tooltipTargetWidth - The width of the tooltip's target
70
+ * @param {Number } tooltipTargetHeight - The height of the tooltip's target
70
71
* @returns {Boolean }
71
72
*/
72
- function isOverlappingAtTop ( xOffset , yOffset , tooltip , tooltipTargetWidth ) {
73
+ function isOverlappingAtTop ( xOffset , yOffset , tooltip , tooltipTargetWidth , tooltipTargetHeight ) {
73
74
if ( typeof document . elementFromPoint !== 'function' ) {
74
75
return false ;
75
76
}
@@ -88,8 +89,8 @@ function isOverlappingAtTop(xOffset, yOffset, tooltip, tooltipTargetWidth) {
88
89
const rectAtTargetCenterX = elementAtTargetCenterX . getBoundingClientRect ( ) ;
89
90
90
91
// Ensure it's not overlapping with another element by checking if the yOffset is greater than the top of the element
91
- // and less than the bottom of the element
92
- const isOverlappingAtTargetCenterX = yOffset > rectAtTargetCenterX . top && yOffset < rectAtTargetCenterX . bottom ;
92
+ // and less than the bottom of the element. Also ensure the tooltip target is not completely inside the elementAtTargetCenterX by vertical direction
93
+ const isOverlappingAtTargetCenterX = yOffset > rectAtTargetCenterX . top && yOffset < rectAtTargetCenterX . bottom && yOffset + tooltipTargetHeight > rectAtTargetCenterX . bottom ;
93
94
94
95
return isOverlappingAtTargetCenterX ;
95
96
}
@@ -156,7 +157,7 @@ export default function getTooltipStyles(
156
157
// If either a tooltip will try to render within GUTTER_WIDTH logical pixels of the top of the screen,
157
158
// Or the wrapped component is overlapping at top-center with another element
158
159
// we'll display it beneath its wrapped component rather than above it as usual.
159
- shouldShowBelow = yOffset - tooltipHeight < GUTTER_WIDTH || isOverlappingAtTop ( xOffset , yOffset , tooltip , tooltipTargetWidth ) ;
160
+ shouldShowBelow = yOffset - tooltipHeight < GUTTER_WIDTH || isOverlappingAtTop ( xOffset , yOffset , tooltip , tooltipTargetWidth , tooltipTargetHeight ) ;
160
161
161
162
// When the tooltip size is ready, we can start animating the scale.
162
163
scale = currentSize ;
0 commit comments