diff --git a/native/tooltip/tooltip-context.react.js b/native/tooltip/tooltip-context.react.js --- a/native/tooltip/tooltip-context.react.js +++ b/native/tooltip/tooltip-context.react.js @@ -3,6 +3,7 @@ import { useActionSheet } from '@expo/react-native-action-sheet'; import * as React from 'react'; import { Platform, StyleSheet } from 'react-native'; +import { useSharedValue, type SharedValue } from 'react-native-reanimated'; import type { TooltipItemBaseProps } from './tooltip-item.react'; @@ -17,6 +18,7 @@ +showActionSheet: () => void, +shouldShowMore: () => boolean, +getNumVisibleEntries: () => number, + +showEmojiKeyboard: SharedValue, }; const TooltipContext: React.Context = React.createContext(); @@ -153,6 +155,8 @@ return Math.min(optionsToDisplay.length, maxOptionsToDisplay); }, [maxOptionsToDisplay, visibleEntryIDsSet]); + const showEmojiKeyboard = useSharedValue(false); + const context = React.useMemo( () => ({ registerOption, @@ -160,6 +164,7 @@ showActionSheet, shouldShowMore, getNumVisibleEntries, + showEmojiKeyboard, }), [ registerOption, @@ -167,6 +172,7 @@ showActionSheet, shouldShowMore, getNumVisibleEntries, + showEmojiKeyboard, ], ); const { children } = props; diff --git a/native/tooltip/tooltip.react.js b/native/tooltip/tooltip.react.js --- a/native/tooltip/tooltip.react.js +++ b/native/tooltip/tooltip.react.js @@ -85,7 +85,6 @@ +actionSheetShown: SharedValue, +hideTooltip: boolean, +setHideTooltip: SetState, - +showEmojiKeyboard: SharedValue, +exitAnimationWorklet: (finished: boolean) => void, +styles: typeof unboundStyles, +tooltipContext: TooltipContextType, @@ -304,7 +303,6 @@ actionSheetShown, hideTooltip, setHideTooltip, - showEmojiKeyboard, exitAnimationWorklet, styles, tooltipContext, @@ -377,7 +375,7 @@ progress: position, isOpeningSidebar, setHideTooltip, - showEmojiKeyboard, + showEmojiKeyboard: tooltipContext.showEmojiKeyboard, }; const itemsStyles = [styles.items, styles.itemsFixed]; @@ -403,7 +401,7 @@ } else if ( this.tooltipLocation === 'fixed' && !hideTooltip && - !showEmojiKeyboard.value + !tooltipContext.showEmojiKeyboard.value ) { tooltip = ( (false); - const showEmojiKeyboard = useSharedValue(false); + const tooltipContext = React.useContext(TooltipContext); + invariant(tooltipContext, 'TooltipContext should be set in Tooltip'); const { goBackOnce } = props.navigation; const goBackCallback = React.useCallback(() => { - if (!actionSheetShown.value) { + if (!actionSheetShown.value && !tooltipContext.showEmojiKeyboard.value) { goBackOnce(); } - }, [actionSheetShown.value, goBackOnce]); + }, [ + actionSheetShown.value, + goBackOnce, + tooltipContext.showEmojiKeyboard.value, + ]); const exitAnimationWorklet = React.useCallback( finished => { @@ -504,8 +507,13 @@ } else { goBackOnce(); } - showEmojiKeyboard.value = false; - }, [isFixed, actionSheetShown.value, goBackOnce, showEmojiKeyboard]); + tooltipContext.showEmojiKeyboard.value = false; + }, [ + isFixed, + actionSheetShown.value, + tooltipContext.showEmojiKeyboard, + goBackOnce, + ]); const styles = useStyles(unboundStyles); const boundTooltipItem = React.useCallback( @@ -524,8 +532,6 @@ [isFixed, styles, closeTooltip], ); - const tooltipContext = React.useContext(TooltipContext); - invariant(tooltipContext, 'TooltipContext should be set in Tooltip'); return (