Skip to content

Commit

Permalink
Merge pull request #54913 from Expensify/revert-54533-fix/54453-smoot…
Browse files Browse the repository at this point in the history
…h-modal-keyboard-handling

[CP Staging] Revert "fix: smooth keyboard handling in BaseModal"

(cherry picked from commit 28d8648)

(CP triggered by thienlnam)
  • Loading branch information
thienlnam authored and OSBotify committed Jan 7, 2025
1 parent 7a6ad66 commit 9bb9f9b
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/components/Modal/BaseModal.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import {PortalHost} from '@gorhom/portal';
import React, {forwardRef, useCallback, useEffect, useMemo, useRef} from 'react';
import {Animated, View} from 'react-native';
import {useKeyboardAnimation} from 'react-native-keyboard-controller';
import {View} from 'react-native';
import ReactNativeModal from 'react-native-modal';
import ColorSchemeWrapper from '@components/ColorSchemeWrapper';
import FocusTrapForModal from '@components/FocusTrap/FocusTrapForModal';
import useKeyboardState from '@hooks/useKeyboardState';
import usePrevious from '@hooks/usePrevious';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useSafeAreaInsets from '@hooks/useSafeAreaInsets';
import useStyledSafeAreaInsets from '@hooks/useStyledSafeAreaInsets';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -65,6 +64,7 @@ function BaseModal(
// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to apply correct modal width
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
const {isSmallScreenWidth} = useResponsiveLayout();
const keyboardStateContextValue = useKeyboardState();

const safeAreaInsets = useSafeAreaInsets();

Expand Down Expand Up @@ -194,7 +194,7 @@ function BaseModal(
safeAreaPaddingRight,
shouldAddBottomSafeAreaMargin,
shouldAddTopSafeAreaMargin,
shouldAddBottomSafeAreaPadding,
shouldAddBottomSafeAreaPadding: (!avoidKeyboard || !keyboardStateContextValue?.isKeyboardShown) && shouldAddBottomSafeAreaPadding,
shouldAddTopSafeAreaPadding,
modalContainerStyleMarginTop: modalContainerStyle.marginTop,
modalContainerStyleMarginBottom: modalContainerStyle.marginBottom,
Expand All @@ -214,13 +214,6 @@ function BaseModal(
}),
[isVisible, type],
);
const {height, progress} = useKeyboardAnimation();
const {unmodifiedPaddings} = useStyledSafeAreaInsets();
const removeSafeAreaPadding = progress.interpolate({
inputRange: [0, 1],
outputRange: [0, unmodifiedPaddings.bottom],
extrapolate: 'clamp',
});

return (
<ModalContext.Provider value={modalContextValue}>
Expand Down Expand Up @@ -267,6 +260,7 @@ function BaseModal(
statusBarTranslucent={statusBarTranslucent}
navigationBarTranslucent={navigationBarTranslucent}
onLayout={onLayout}
avoidKeyboard={avoidKeyboard}
customBackdrop={shouldUseCustomBackdrop ? <Overlay onPress={handleBackdropPress} /> : undefined}
>
<ModalContent
Expand All @@ -278,18 +272,12 @@ function BaseModal(
active={isVisible}
initialFocus={initialFocus}
>
<Animated.View
style={[
styles.defaultModalContainer,
modalPaddingStyles,
modalContainerStyle,
!isVisible && styles.pointerEventsNone,
avoidKeyboard && {transform: [{translateY: Animated.add(height, removeSafeAreaPadding)}]},
]}
<View
style={[styles.defaultModalContainer, modalPaddingStyles, modalContainerStyle, !isVisible && styles.pointerEventsNone]}
ref={ref}
>
<ColorSchemeWrapper>{children}</ColorSchemeWrapper>
</Animated.View>
</View>
</FocusTrapForModal>
</ModalContent>
</ReactNativeModal>
Expand Down

0 comments on commit 9bb9f9b

Please sign in to comment.