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,13 @@ 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
3435 const renderTooltip = useCallback ( ( ) => {
35- if ( ! tooltipElementRef . current || ! genericTooltipStateRef . current ) {
36+ if ( ! tooltipElementRef . current || ! genericTooltipStateRef . current || ( ! isFocused && shouldHideOnNavigate ) ) {
3637 return ;
3738 }
3839
@@ -65,7 +66,7 @@ function BaseEducationalTooltip({children, shouldRender = false, shouldHideOnNav
6566 showTooltip ( ) ;
6667 }
6768 } ) ;
68- } , [ insets ] ) ;
69+ } , [ insets . bottom , insets . left , insets . right , insets . top , isFocused , shouldHideOnNavigate ] ) ;
6970
7071 useEffect ( ( ) => {
7172 if ( ! genericTooltipStateRef . current || ! shouldRender ) {
@@ -120,7 +121,7 @@ function BaseEducationalTooltip({children, shouldRender = false, shouldHideOnNav
120121 } , [ ] ) ;
121122
122123 useEffect ( ( ) => {
123- if ( ! shouldMeasure ) {
124+ if ( ! shouldMeasure || ( ! isFocused && shouldHideOnNavigate ) ) {
124125 return ;
125126 }
126127 if ( ! shouldRender ) {
@@ -134,7 +135,7 @@ function BaseEducationalTooltip({children, shouldRender = false, shouldHideOnNav
134135 return ( ) => {
135136 clearTimeout ( timerID ) ;
136137 } ;
137- } , [ shouldMeasure , shouldRender ] ) ;
138+ } , [ shouldMeasure , shouldRender , isFocused , shouldHideOnNavigate ] ) ;
138139
139140 useEffect ( ( ) => {
140141 if ( ! navigator ) {
0 commit comments