Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tooltip overlaps with the desktop header #38806

Merged
8 changes: 6 additions & 2 deletions src/styles/utils/generators/TooltipStyleUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import FontUtils from '@styles/utils/FontUtils';
import positioning from '@styles/utils/positioning';
// eslint-disable-next-line no-restricted-imports
import spacing from '@styles/utils/spacing';
// eslint-disable-next-line no-restricted-imports
import titleBarHeight from '@styles/utils/titleBarHeight';
import variables from '@styles/variables';
import type StyleUtilGenerator from './types';

Expand Down Expand Up @@ -181,11 +183,13 @@ const createTooltipStyleUtils: StyleUtilGenerator<GetTooltipStylesStyleUtil> = (

if (isTooltipSizeReady) {
// Determine if the tooltip should display below the wrapped component.
// If either a tooltip will try to render within GUTTER_WIDTH logical pixels of the top of the screen,
// If either a tooltip will try to render within GUTTER_WIDTH or desktop header logical pixels of the top of the screen,
// Or the wrapped component is overlapping at top-center with another element
// we'll display it beneath its wrapped component rather than above it as usual.
shouldShowBelow =
shouldForceRenderingBelow || yOffset - tooltipHeight < GUTTER_WIDTH || !!(tooltip && isOverlappingAtTop(tooltip, xOffset, yOffset, tooltipTargetWidth, tooltipTargetHeight));
shouldForceRenderingBelow ||
yOffset - tooltipHeight - POINTER_HEIGHT < GUTTER_WIDTH + titleBarHeight ||
!!(tooltip && isOverlappingAtTop(tooltip, xOffset, yOffset, tooltipTargetWidth, tooltipTargetHeight));

// When the tooltip size is ready, we can start animating the scale.
scale = currentSize;
Expand Down
1 change: 1 addition & 0 deletions src/styles/utils/titleBarHeight/index.desktop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 28;
1 change: 1 addition & 0 deletions src/styles/utils/titleBarHeight/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default 0;
Loading