diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 2f1d459e369a..a0143f87e789 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -1,6 +1,6 @@ import {useFocusEffect, useIsFocused} from '@react-navigation/native'; import lodashIsEqual from 'lodash/isEqual'; -import React, {memo, useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react'; +import React, {memo, useCallback, useEffect, useMemo, useRef, useState} from 'react'; import {InteractionManager, View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import {useOnyx} from 'react-native-onyx'; @@ -46,7 +46,6 @@ import type {SectionListDataType} from './SelectionList/types'; import UserListItem from './SelectionList/UserListItem'; import SettlementButton from './SettlementButton'; import Text from './Text'; -import {KeyboardStateContext} from './withKeyboardState'; type MoneyRequestConfirmationListProps = { /** Callback to inform parent modal of success */ @@ -195,7 +194,7 @@ function MoneyRequestConfirmationList({ const styles = useThemeStyles(); const {translate, toLocaleDigit} = useLocalize(); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); - const {isKeyboardShown, isWindowHeightReducedByKeyboard} = useContext(KeyboardStateContext); + const isTypeRequest = iouType === CONST.IOU.TYPE.SUBMIT; const isTypeSplit = iouType === CONST.IOU.TYPE.SPLIT; const isTypeSend = iouType === CONST.IOU.TYPE.PAY; @@ -825,7 +824,7 @@ function MoneyRequestConfirmationList({ }, [routeError, isTypeSplit, shouldShowReadOnlySplits, debouncedFormError, formError, translate]); const footerContent = useMemo(() => { - if (isReadOnly || isKeyboardShown || isWindowHeightReducedByKeyboard) { + if (isReadOnly) { return; } @@ -877,20 +876,7 @@ function MoneyRequestConfirmationList({ {button} ); - }, [ - isReadOnly, - iouType, - confirm, - bankAccountRoute, - iouCurrencyCode, - policyID, - splitOrRequestOptions, - styles.ph1, - styles.mb2, - errorMessage, - isKeyboardShown, - isWindowHeightReducedByKeyboard, - ]); + }, [isReadOnly, iouType, confirm, bankAccountRoute, iouCurrencyCode, policyID, splitOrRequestOptions, styles.ph1, styles.mb2, errorMessage]); const listFooterContent = ( ({ @@ -23,7 +19,6 @@ const KeyboardStateContext = createContext({ function KeyboardStateProvider({children}: ChildrenProps): ReactElement | null { const [keyboardHeight, setKeyboardHeight] = useState(0); - const isWindowHeightReducedByKeyboard = useIsWindowHeightReducedByKeyboard(); useEffect(() => { const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', (e) => { @@ -43,9 +38,8 @@ function KeyboardStateProvider({children}: ChildrenProps): ReactElement | null { () => ({ keyboardHeight, isKeyboardShown: keyboardHeight !== 0, - isWindowHeightReducedByKeyboard, }), - [keyboardHeight, isWindowHeightReducedByKeyboard], + [keyboardHeight], ); return {children}; } diff --git a/src/hooks/useIsWindowHeightReducedByKeyboard/index.ts b/src/hooks/useIsWindowHeightReducedByKeyboard/index.ts deleted file mode 100644 index 7895c7209115..000000000000 --- a/src/hooks/useIsWindowHeightReducedByKeyboard/index.ts +++ /dev/null @@ -1,37 +0,0 @@ -import {useCallback, useEffect, useState} from 'react'; -import usePrevious from '@hooks/usePrevious'; -import useResponsiveLayout from '@hooks/useResponsiveLayout'; -import useWindowDimensions from '@hooks/useWindowDimensions'; - -const useIsWindowHeightReducedByKeyboard = () => { - const [isWindowHeightReducedByKeyboard, setIsWindowHeightReducedByKeyboard] = useState(false); - const {windowHeight} = useWindowDimensions(); - const prevWindowHeight = usePrevious(windowHeight); - const {shouldUseNarrowLayout} = useResponsiveLayout(); - const toggleKeyboardOnSmallScreens = useCallback( - (isKBOpen: boolean) => { - if (!shouldUseNarrowLayout) { - return; - } - setIsWindowHeightReducedByKeyboard(isKBOpen); - }, - [shouldUseNarrowLayout], - ); - useEffect(() => { - // Use window height changes to toggle the keyboard. To maintain keyboard state - // on all platforms we also use focus/blur events. So we need to make sure here - // that we avoid redundant keyboard toggling. - // Minus 100px is needed to make sure that when the internet connection is - // disabled in android chrome and a small 'No internet connection' text box appears, - // we do not take it as a sign to open the keyboard - if (!isWindowHeightReducedByKeyboard && windowHeight < prevWindowHeight - 100) { - toggleKeyboardOnSmallScreens(true); - } else if (isWindowHeightReducedByKeyboard && windowHeight > prevWindowHeight) { - toggleKeyboardOnSmallScreens(false); - } - }, [isWindowHeightReducedByKeyboard, prevWindowHeight, toggleKeyboardOnSmallScreens, windowHeight]); - - return isWindowHeightReducedByKeyboard; -}; - -export default useIsWindowHeightReducedByKeyboard;