From b0c36383a9a7304f94c2bb19f7cc4b37e0b4f637 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Mon, 25 Nov 2024 20:30:15 +0000 Subject: Ensure react-native-keyboard-controller enabled state doesn't get overwritten (#6727) * revert to prev state instead of false * add dep array * use ref counting approach * patch keyboard controller to allow changing the enabled prop * remove state from patch * change patched prop name * remove Math.max check, log if < 0 * use noop provider * rm patch, use `useRef` * Style nits * Rm on web --------- Co-authored-by: Dan Abramov --- src/components/Dialog/index.tsx | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'src/components/Dialog') diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index f16a9925d..c424321be 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -11,7 +11,6 @@ import { } from 'react-native' import { KeyboardAwareScrollView, - useKeyboardController, useKeyboardHandler, } from 'react-native-keyboard-controller' import {runOnJS} from 'react-native-reanimated' @@ -20,6 +19,7 @@ import {useSafeAreaInsets} from 'react-native-safe-area-context' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {useEnableKeyboardController} from '#/lib/hooks/useEnableKeyboardController' import {ScrollProvider} from '#/lib/ScrollContext' import {logger} from '#/logger' import {isAndroid, isIOS} from '#/platform/detection' @@ -199,20 +199,10 @@ export const ScrollableInner = React.forwardRef( ) { const {nativeSnapPoint, disableDrag, setDisableDrag} = useDialogContext() const insets = useSafeAreaInsets() - const {setEnabled} = useKeyboardController() - const [keyboardHeight, setKeyboardHeight] = React.useState(0) - - React.useEffect(() => { - if (!isIOS) { - return - } + useEnableKeyboardController(isIOS) - setEnabled(true) - return () => { - setEnabled(false) - } - }) + const [keyboardHeight, setKeyboardHeight] = React.useState(0) useKeyboardHandler( { -- cgit 1.4.1