diff --git a/packages/ui/src/components/tooltip/Tooltip.web.tsx b/packages/ui/src/components/tooltip/Tooltip.web.tsx index 6370ed9a782..849ab1c0d83 100644 --- a/packages/ui/src/components/tooltip/Tooltip.web.tsx +++ b/packages/ui/src/components/tooltip/Tooltip.web.tsx @@ -1,7 +1,9 @@ import { AdaptParent } from '@tamagui/adapt' -import { useEffect, useId } from 'react' +import { useContext, useEffect, useId } from 'react' import { styled, Tooltip as TamaguiTooltip, withStaticProperties } from 'tamagui' +import { EffectiveModalOrSheetZIndexContext } from 'ui/src/components/modal/AdaptiveWebModal' import { TooltipContentProps } from 'ui/src/components/tooltip/Tooltip' +import { zIndexes } from 'ui/src/theme' import { useEvent } from 'utilities/src/react/hooks' import { useBooleanState } from 'utilities/src/react/useBooleanState' @@ -13,7 +15,10 @@ const StyledContent = styled(TamaguiTooltip.Content) StyledContent.displayName = 'StyledContent' const HigherOrderStyledContent = StyledContent.styleable((props) => { - const { animationDirection = 'top' } = props + const { animationDirection = 'top', zIndex: zIndexProp, ...rest } = props + + const effectiveModalZ = useContext(EffectiveModalOrSheetZIndexContext) + const resolvedZIndex = Math.max(zIndexProp ?? 0, (effectiveModalZ ?? 0) + 1, zIndexes.tooltip) const animationStyles: { opacity: 0 @@ -38,7 +43,7 @@ const HigherOrderStyledContent = StyledContent.styleable((p break } - return + return }) HigherOrderStyledContent.displayName = 'HigherOrderStyledContent'