Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix: Submit button hang in middle page" #52976

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -825,7 +824,7 @@ function MoneyRequestConfirmationList({
}, [routeError, isTypeSplit, shouldShowReadOnlySplits, debouncedFormError, formError, translate]);

const footerContent = useMemo(() => {
if (isReadOnly || isKeyboardShown || isWindowHeightReducedByKeyboard) {
if (isReadOnly) {
return;
}

Expand Down Expand Up @@ -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 = (
<MoneyRequestConfirmationListFooter
Expand Down
8 changes: 1 addition & 7 deletions src/components/withKeyboardState.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type {ComponentType, ForwardedRef, ReactElement, RefAttributes} from 'react';
import React, {createContext, forwardRef, useEffect, useMemo, useState} from 'react';
import {Keyboard} from 'react-native';
import useIsWindowHeightReducedByKeyboard from '@hooks/useIsWindowHeightReducedByKeyboard';
import getComponentDisplayName from '@libs/getComponentDisplayName';
import type ChildrenProps from '@src/types/utils/ChildrenProps';

Expand All @@ -11,9 +10,6 @@ type KeyboardStateContextValue = {

/** Height of the keyboard in pixels */
keyboardHeight: number;

/** Whether window height is smaller than usual due to the keyboard being open */
isWindowHeightReducedByKeyboard?: boolean;
};

const KeyboardStateContext = createContext<KeyboardStateContextValue>({
Expand All @@ -23,7 +19,6 @@ const KeyboardStateContext = createContext<KeyboardStateContextValue>({

function KeyboardStateProvider({children}: ChildrenProps): ReactElement | null {
const [keyboardHeight, setKeyboardHeight] = useState(0);
const isWindowHeightReducedByKeyboard = useIsWindowHeightReducedByKeyboard();

useEffect(() => {
const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', (e) => {
Expand All @@ -43,9 +38,8 @@ function KeyboardStateProvider({children}: ChildrenProps): ReactElement | null {
() => ({
keyboardHeight,
isKeyboardShown: keyboardHeight !== 0,
isWindowHeightReducedByKeyboard,
}),
[keyboardHeight, isWindowHeightReducedByKeyboard],
[keyboardHeight],
);
return <KeyboardStateContext.Provider value={contextValue}>{children}</KeyboardStateContext.Provider>;
}
Expand Down
37 changes: 0 additions & 37 deletions src/hooks/useIsWindowHeightReducedByKeyboard/index.ts

This file was deleted.

Loading