@@ -9,6 +9,7 @@ import CONST from '@src/CONST';
99import ONYXKEYS from '@src/ONYXKEYS' ;
1010import { personalDetailsLoginSelector } from '@src/selectors/PersonalDetails' ;
1111import type AnchorAlignment from '@src/types/utils/AnchorAlignment' ;
12+ import calculateModalHeightInLandscapeMode from '@src/utils/calculateModalHeightInLandscapeMode' ;
1213
1314import type { RefObject } from 'react' ;
1415
@@ -17,10 +18,12 @@ import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
1718import { View } from 'react-native' ;
1819
1920import useIsInLandscapeMode from './useIsInLandscapeMode' ;
21+ import useKeyboardState from './useKeyboardState' ;
2022import useOnyx from './useOnyx' ;
2123import usePopoverPosition from './usePopoverPosition' ;
2224import usePrevious from './usePrevious' ;
2325import useResponsiveLayout from './useResponsiveLayout' ;
26+ import useSafeAreaInsets from './useSafeAreaInsets' ;
2427import useStyleUtils from './useStyleUtils' ;
2528import useThemeStyles from './useThemeStyles' ;
2629import useViewportOffsetTop from './useViewportOffsetTop' ;
@@ -60,15 +63,18 @@ function useReportSubmitToPopover({reportID, onSubmitSuccess, anchorAlignment =
6063 // Bottom-docked Modal path only; aligns with Popover path that omits modal shell padding chrome
6164 // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
6265 const { isSmallScreenWidth} = useResponsiveLayout ( ) ;
63- const isBottomDockedInLandscape = isSmallScreenWidth && isInLandscapeMode ;
66+ const { keyboardActiveHeight} = useKeyboardState ( ) ;
67+ const { top : topSafeAreaInset } = useSafeAreaInsets ( ) ;
6468
6569 const submitToPopoverContentHeight = useMemo ( ( ) => {
66- if ( ! isBottomDockedInLandscape ) {
70+ if ( ! isInLandscapeMode ) {
6771 return popoverDimensions . height ;
6872 }
6973
70- return Math . min ( popoverDimensions . height , windowHeight * CONST . MODAL_MAX_HEIGHT_TO_WINDOW_HEIGHT_RATIO_LANDSCAPE_MODE ) ;
71- } , [ isBottomDockedInLandscape , windowHeight ] ) ;
74+ const contentHeightLandscapeMode = calculateModalHeightInLandscapeMode ( windowHeight , topSafeAreaInset , keyboardActiveHeight ) ;
75+
76+ return Math . min ( popoverDimensions . height , contentHeightLandscapeMode ) ;
77+ } , [ isInLandscapeMode , windowHeight , keyboardActiveHeight , topSafeAreaInset ] ) ;
7278 const anchorRef = useRef < View > ( null ) ;
7379 const oneShotOnSubmitSuccessRef = useRef < ( ( ) => void ) | undefined > ( undefined ) ;
7480 const onSubmitWithManagerEmailRef = useRef < ReportSubmitToPopoverOpenOptions [ 'onSubmitWithManagerEmail' ] > ( undefined ) ;
@@ -227,9 +233,9 @@ function useReportSubmitToPopover({reportID, onSubmitSuccess, anchorAlignment =
227233 const innerContainerStyle = useMemo (
228234 ( ) => ( {
229235 ...popoverContainerStyle ,
230- ...( isBottomDockedInLandscape ? styles . getPopoverMaxHeight ( windowHeight , true ) : { minHeight : popoverDimensions . minHeight } ) ,
236+ ...( isInLandscapeMode ? styles . getPopoverMaxHeight ( windowHeight , true ) : { minHeight : popoverDimensions . minHeight } ) ,
231237 } ) ,
232- [ popoverContainerStyle , isBottomDockedInLandscape , windowHeight , styles ] ,
238+ [ popoverContainerStyle , isInLandscapeMode , windowHeight , styles ] ,
233239 ) ;
234240
235241 const reportSubmitToPopover = useMemo ( ( ) => {
@@ -259,7 +265,7 @@ function useReportSubmitToPopover({reportID, onSubmitSuccess, anchorAlignment =
259265 >
260266 < View
261267 collapsable = { false }
262- style = { [ StyleUtils . getHeight ( submitToPopoverContentHeight ) , styles . flexColumn , styles . flex1 , styles . w100 , styles . pt4 ] }
268+ style = { [ StyleUtils . getHeight ( submitToPopoverContentHeight ) , styles . flexColumn , ! isInLandscapeMode && styles . flex1 , styles . w100 , styles . pt4 ] }
263269 >
264270 < ReportSubmitToContent
265271 key = { submitToContentKey }
@@ -276,28 +282,28 @@ function useReportSubmitToPopover({reportID, onSubmitSuccess, anchorAlignment =
276282 </ PopoverWithMeasuredContent >
277283 ) ;
278284 } , [
279- StyleUtils ,
280- styles . flexColumn ,
281- styles . flex1 ,
282- styles . pt4 ,
283- styles . w100 ,
285+ shouldRenderSubmitToPopover ,
284286 innerContainerStyle ,
285287 outerStyle ,
286- submitToPopoverContentHeight ,
287- shouldRenderSubmitToPopover ,
288288 isVisible ,
289289 closeReportSubmitToPopover ,
290290 handleReportSubmitToPopoverModalHide ,
291291 anchorPosition ,
292292 anchorAlignment ,
293- anchorRef ,
293+ StyleUtils ,
294+ submitToPopoverContentHeight ,
295+ styles . flexColumn ,
296+ styles . flex1 ,
297+ styles . w100 ,
298+ styles . pt4 ,
299+ isInLandscapeMode ,
300+ submitToContentKey ,
294301 report ,
295302 policy ,
296303 isLoadingReportData ,
297304 handleCombinedSubmitSuccess ,
298305 isSearchSubmitFlow ,
299306 handleSearchSubmitWithManagerEmail ,
300- submitToContentKey ,
301307 ] ) ;
302308
303309 return {
0 commit comments