diff --git a/src/lib/viewers/controls/annotations/AnnotationsTargetedTooltip.tsx b/src/lib/viewers/controls/annotations/AnnotationsTargetedTooltip.tsx index 969d14c0b..6de7c1d86 100644 --- a/src/lib/viewers/controls/annotations/AnnotationsTargetedTooltip.tsx +++ b/src/lib/viewers/controls/annotations/AnnotationsTargetedTooltip.tsx @@ -12,24 +12,11 @@ export type Props = React.PropsWithChildren<{ function AnnotationsTargetedTooltip({ children, isEnabled = false }: Props): JSX.Element | null { const { experiences } = React.useContext(ExperiencesContext); const { setIsForced } = React.useContext(ControlsLayerContext); - const [shouldTargetAnnotationsTooltip, setShouldTargetAnnotationsTooltip] = React.useState(true); - const [wasClosedByUser, setWasClosedByUser] = React.useState(false); - - const shouldTarget = !!( - isEnabled && - experiences && - experiences.tooltipFlowAnnotationsExperience && - experiences.tooltipFlowAnnotationsExperience.canShow - ); - - if (!shouldTarget) { - return <>{children}; - } return ( @@ -47,16 +34,10 @@ function AnnotationsTargetedTooltip({ children, isEnabled = false }: Props): JSX }, onComplete: (): void => { experiences.tooltipFlowAnnotationsExperience.onComplete(); - setShouldTargetAnnotationsTooltip(false); + setIsForced(false); }, onShow: (): void => { experiences.tooltipFlowAnnotationsExperience.onShow(); - - if (wasClosedByUser) { - return; - } - - setWasClosedByUser(true); setIsForced(true); }, }; diff --git a/src/lib/viewers/controls/annotations/__tests__/AnnotationsControls-test.tsx b/src/lib/viewers/controls/annotations/__tests__/AnnotationsControls-test.tsx index c5c096c32..7e07f4390 100644 --- a/src/lib/viewers/controls/annotations/__tests__/AnnotationsControls-test.tsx +++ b/src/lib/viewers/controls/annotations/__tests__/AnnotationsControls-test.tsx @@ -20,8 +20,12 @@ describe('AnnotationsControls', () => { }; beforeEach(() => { + let found = false; // we want to find the first use of useEffect jest.spyOn(React, 'useEffect').mockImplementation(cb => { - unmount = cb() as () => void; // Enzyme unmount helper does not currently invoke useEffect cleanup + if (!found) { + found = true; + unmount = cb() as () => void; // Enzyme unmount helper does not currently invoke useEffect cleanup + } }); }); diff --git a/src/lib/viewers/controls/annotations/__tests__/AnnotationsTargetedTooltip-test.tsx b/src/lib/viewers/controls/annotations/__tests__/AnnotationsTargetedTooltip-test.tsx index 9a5fdcdc7..87e1c8d9d 100644 --- a/src/lib/viewers/controls/annotations/__tests__/AnnotationsTargetedTooltip-test.tsx +++ b/src/lib/viewers/controls/annotations/__tests__/AnnotationsTargetedTooltip-test.tsx @@ -42,7 +42,7 @@ describe('AnnotationsTargetedTooltip', () => { }); expect(wrapper.children().text()).toBe('Child'); - expect(wrapper.children().prop('shouldTarget')).toBe(undefined); + expect(wrapper.children().prop('shouldTarget')).toBe(false); }); }); });