Skip to content

Commit f5e7b2f

Browse files
committed
refactor: resolve attachment keyboard avoidance by platform
1 parent 92083a6 commit f5e7b2f

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎src/components/PDFView/index.native.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import useStyleUtils from '@hooks/useStyleUtils';
1111
import useThemeStyles from '@hooks/useThemeStyles';
1212
import useWindowDimensions from '@hooks/useWindowDimensions';
1313

14-
import getPlatform from '@libs/getPlatform';
1514
import {openTravelDotLink} from '@libs/openTravelDotLink';
15+
import shouldEnableAttachmentModalKeyboardAvoidance from '@libs/shouldEnableAttachmentModalKeyboardAvoidance';
1616
import {getRelativeUrl, isTravelLink} from '@libs/TravelUtils';
1717

1818
import CONST from '@src/CONST';
@@ -73,7 +73,7 @@ function PDFView({
7373
const {isKeyboardShown} = useKeyboardState();
7474
const StyleUtils = useStyleUtils();
7575
const {insets} = useSafeAreaPaddings();
76-
const shouldAvoidPasswordKeyboard = !!isUsedInAttachmentModal && getPlatform() === CONST.PLATFORM.IOS;
76+
const shouldAvoidPasswordKeyboard = !!isUsedInAttachmentModal && !shouldEnableAttachmentModalKeyboardAvoidance;
7777

7878
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
7979

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Avoid the password keyboard inside the PDF form so the attachment pager does not resize.
2+
const shouldEnableAttachmentModalKeyboardAvoidance = false;
3+
4+
export default shouldEnableAttachmentModalKeyboardAvoidance;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Keep screen-level keyboard avoidance on Android.
2+
const shouldEnableAttachmentModalKeyboardAvoidance = true;
3+
4+
export default shouldEnableAttachmentModalKeyboardAvoidance;

‎src/pages/media/AttachmentModalScreen/AttachmentModalContainer/index.native.tsx‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import ScreenWrapper from '@components/ScreenWrapper';
22

33
import attachmentModalHandler from '@libs/AttachmentModalHandler';
4-
import getPlatform from '@libs/getPlatform';
54
import Navigation from '@libs/Navigation/Navigation';
5+
import shouldEnableAttachmentModalKeyboardAvoidance from '@libs/shouldEnableAttachmentModalKeyboardAvoidance';
66

77
import AttachmentModalBaseContent from '@pages/media/AttachmentModalScreen/AttachmentModalBaseContent';
88
import AttachmentStateContextProvider from '@pages/media/AttachmentModalScreen/AttachmentModalBaseContent/AttachmentStateContextProvider';
99
import type {AttachmentModalOnCloseOptions} from '@pages/media/AttachmentModalScreen/AttachmentModalBaseContent/types';
1010
import AttachmentModalContext from '@pages/media/AttachmentModalScreen/AttachmentModalContext';
1111
import type {AttachmentModalScreenType} from '@pages/media/AttachmentModalScreen/types';
1212

13-
import CONST from '@src/CONST';
14-
1513
import {SafeString} from 'expensify-common';
1614
import React, {memo, useCallback, useContext, useEffect} from 'react';
1715

@@ -63,7 +61,7 @@ function AttachmentModalContainer<Screen extends AttachmentModalScreenType>({con
6361
testID={`attachment-modal-${testID}`}
6462
enableEdgeToEdgeBottomSafeAreaPadding
6563
// Keep keyboard avoidance inside the password form so it does not resize the iOS pager.
66-
shouldEnableKeyboardAvoidingView={getPlatform() !== CONST.PLATFORM.IOS}
64+
shouldEnableKeyboardAvoidingView={shouldEnableAttachmentModalKeyboardAvoidance}
6765
>
6866
<AttachmentStateContextProvider>
6967
<AttachmentModalBaseContent

0 commit comments

Comments
 (0)