1- import { NavigationContext } from '@react-navigation/native' ;
1+ import { NavigationContext , useIsFocused } from '@react-navigation/native' ;
22import React , { memo , useCallback , useContext , useEffect , useLayoutEffect , useRef , useState } from 'react' ;
33import type { LayoutRectangle , NativeMethods , NativeSyntheticEvent } from 'react-native' ;
44import { DeviceEventEmitter , Dimensions } from 'react-native' ;
@@ -27,12 +27,15 @@ function BaseEducationalTooltip({children, shouldRender = false, shouldHideOnNav
2727 const show = useRef < ( ( ) => void ) | undefined > ( undefined ) ;
2828
2929 const navigator = useContext ( NavigationContext ) ;
30+ const isFocused = useIsFocused ( ) ;
3031 const insets = useSafeAreaInsets ( ) ;
3132
3233 const isResizing = useIsResizing ( ) ;
3334
35+ const shouldSuppressTooltip = ! isFocused && shouldHideOnNavigate ;
36+
3437 const renderTooltip = useCallback ( ( ) => {
35- if ( ! tooltipElementRef . current || ! genericTooltipStateRef . current ) {
38+ if ( ! tooltipElementRef . current || ! genericTooltipStateRef . current || shouldSuppressTooltip ) {
3639 return ;
3740 }
3841
@@ -65,7 +68,7 @@ function BaseEducationalTooltip({children, shouldRender = false, shouldHideOnNav
6568 showTooltip ( ) ;
6669 }
6770 } ) ;
68- } , [ insets ] ) ;
71+ } , [ insets , shouldSuppressTooltip ] ) ;
6972
7073 useEffect ( ( ) => {
7174 if ( ! genericTooltipStateRef . current || ! shouldRender ) {
@@ -120,7 +123,7 @@ function BaseEducationalTooltip({children, shouldRender = false, shouldHideOnNav
120123 } , [ ] ) ;
121124
122125 useEffect ( ( ) => {
123- if ( ! shouldMeasure ) {
126+ if ( ! shouldMeasure || shouldSuppressTooltip ) {
124127 return ;
125128 }
126129 if ( ! shouldRender ) {
@@ -134,7 +137,7 @@ function BaseEducationalTooltip({children, shouldRender = false, shouldHideOnNav
134137 return ( ) => {
135138 clearTimeout ( timerID ) ;
136139 } ;
137- } , [ shouldMeasure , shouldRender ] ) ;
140+ } , [ shouldMeasure , shouldRender , shouldSuppressTooltip ] ) ;
138141
139142 useEffect ( ( ) => {
140143 if ( ! navigator ) {
0 commit comments