@@ -2,7 +2,7 @@ import styled from 'styled-components';
22import { type ReactNode , useMemo , useRef } from 'react' ;
33import { getFeatureFlagMemo } from '../state/ducks/types/releasedFeaturesReduxTypes' ;
44import { clampNumber } from '../util/maths' ;
5- import { defaultTriggerPos , PopoverTriggerPosition } from './SessionTooltip' ;
5+ import { PopoverTriggerPosition } from './SessionTooltip' ;
66
77const TIP_LENGTH = 18 ;
88const VIEWPORT_MARGIN = 4 ;
@@ -95,7 +95,7 @@ const StyledPopover = styled.div<{
9595export type PopoverProps = {
9696 children : ReactNode ;
9797 pointerOffset ?: number ;
98- triggerPosition : PopoverTriggerPosition ;
98+ triggerPosition : PopoverTriggerPosition | null ;
9999 open : boolean ;
100100 loading ?: boolean ;
101101 maxWidth ?: string ;
@@ -124,7 +124,7 @@ export const SessionPopoverContent = (props: PopoverProps) => {
124124 loading,
125125 maxWidth,
126126 onClick,
127- triggerPosition = defaultTriggerPos ,
127+ triggerPosition,
128128 isTooltip,
129129 contentMargin = 0 ,
130130 containerMarginTop = VIEWPORT_MARGIN ,
@@ -146,8 +146,10 @@ export const SessionPopoverContent = (props: PopoverProps) => {
146146 const viewportWidth = window . innerWidth ;
147147 const viewportHeight = window . innerHeight ;
148148
149+ const show = open && ! loading && ! ! triggerPosition ;
150+
149151 const { x, y, pointerOffset, anchorX, finalVerticalPos, bounds } = useMemo ( ( ) => {
150- if ( ! open || loading ) {
152+ if ( ! show ) {
151153 return {
152154 x : 0 ,
153155 y : 0 ,
@@ -217,15 +219,10 @@ export const SessionPopoverContent = (props: PopoverProps) => {
217219 bounds : { x1 : minX , y1 : minY , x2 : maxX , y2 : maxY } ,
218220 } ;
219221 } , [
220- open ,
221- loading ,
222+ show ,
222223 contentWidth ,
223224 isTooltip ,
224- triggerPosition . x ,
225- triggerPosition . y ,
226- triggerPosition . width ,
227- triggerPosition . height ,
228- triggerPosition . offsetX ,
225+ triggerPosition ,
229226 horizontalPosition ,
230227 viewportWidth ,
231228 verticalPosition ,
@@ -244,7 +241,7 @@ export const SessionPopoverContent = (props: PopoverProps) => {
244241 < >
245242 < StyledPopover
246243 ref = { ref }
247- $readyToShow = { open && ! loading }
244+ $readyToShow = { show }
248245 onClick = { onClick }
249246 x = { x }
250247 y = { y }
@@ -257,7 +254,7 @@ export const SessionPopoverContent = (props: PopoverProps) => {
257254 >
258255 { children }
259256 </ StyledPopover >
260- { showPopoverAnchors && open ? (
257+ { showPopoverAnchors && show ? (
261258 // NOTE: these are only rendered when the debug option is enabled
262259 < >
263260 < StyledCoordinateRectangleMarker title = "allowedArea" $bounds = { bounds } />
0 commit comments