From ab5dd5457908a934ab382fa58f569f9015103a55 Mon Sep 17 00:00:00 2001 From: GCyganek Date: Wed, 5 Aug 2026 15:28:15 +0200 Subject: [PATCH 01/22] Use narrow layout in landscape mode mWeb --- .../SidePanel/SidePanelModal/index.tsx | 4 +- src/hooks/useIsInLandscapeMode/index.ts | 11 ++++- src/hooks/useResponsiveLayout/index.ts | 12 ++++-- src/hooks/useSafeAreaPaddings.ts | 6 ++- .../useModalStackScreenOptions.ts | 4 +- .../useRootNavigatorScreenOptions.ts | 6 ++- .../useSplitNavigatorScreenOptions.ts | 7 +++- src/libs/getIsNarrowLayout/index.ts | 3 +- src/libs/isInLandscapeMode/index.ts | 12 +++--- .../step/IOURequestStepDistanceGPS/index.tsx | 41 ++++++++++--------- .../step/IOURequestStepDistanceOdometer.tsx | 5 ++- 11 files changed, 71 insertions(+), 40 deletions(-) diff --git a/src/components/SidePanel/SidePanelModal/index.tsx b/src/components/SidePanel/SidePanelModal/index.tsx index cd6817940d7c..7df699dad6d0 100644 --- a/src/components/SidePanel/SidePanelModal/index.tsx +++ b/src/components/SidePanel/SidePanelModal/index.tsx @@ -27,7 +27,7 @@ import type SidePanelModalProps from './types'; function SidePanelModal({children, sidePanelTranslateX, closeSidePanel, shouldHideSidePanelBackdrop}: SidePanelModalProps) { const styles = useThemeStyles(); const {isExtraLargeScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout(); - const {paddingTop, paddingBottom} = useSafeAreaPaddings(); + const {paddingTop, paddingBottom, paddingLeft, paddingRight} = useSafeAreaPaddings(); const [isRHPVisible = false] = useOnyx(ONYXKEYS.MODAL, {selector: isRHPVisibleSelector}); const uniqueModalId = ComposerFocusManager.getId(); @@ -85,7 +85,7 @@ function SidePanelModal({children, sidePanelTranslateX, closeSidePanel, shouldHi styles.sidePanelContent, styles.sidePanelContentWidth(shouldUseNarrowLayout), styles.sidePanelContentBorderWidth(isExtraLargeScreenWidth), - {transform: [{translateX: sidePanelTranslateX.current}], paddingTop, paddingBottom}, + {transform: [{translateX: sidePanelTranslateX.current}], paddingTop, paddingBottom, paddingLeft, paddingRight}, ]} > {children} diff --git a/src/hooks/useIsInLandscapeMode/index.ts b/src/hooks/useIsInLandscapeMode/index.ts index 01775a6d2c34..b2b014a18625 100644 --- a/src/hooks/useIsInLandscapeMode/index.ts +++ b/src/hooks/useIsInLandscapeMode/index.ts @@ -1,8 +1,15 @@ +import useWindowDimensions from '@hooks/useWindowDimensions'; + +import isInLandscapeMode from '@libs/isInLandscapeMode'; /** - * We only want to change UI according to the landscape mode on native platforms. + * Returns whether mWeb is currently in landscape orientation. + * If component already uses useResponsiveLayout, it will return the value from that hook. + * If component already uses useWindowDimensions, use @libs/isInLandscapeMode instead. */ function useIsInLandscapeMode(): boolean { - return false; + const {windowWidth, windowHeight} = useWindowDimensions(); + + return isInLandscapeMode(windowWidth, windowHeight); } export default useIsInLandscapeMode; diff --git a/src/hooks/useResponsiveLayout/index.ts b/src/hooks/useResponsiveLayout/index.ts index ba8e6a046244..882eba412fe7 100644 --- a/src/hooks/useResponsiveLayout/index.ts +++ b/src/hooks/useResponsiveLayout/index.ts @@ -2,6 +2,8 @@ import ModalContext from '@components/Modal/ModalContext'; import useWindowDimensions from '@hooks/useWindowDimensions'; +import isInLandscapeModeUtil from '@libs/isInLandscapeMode'; + import variables from '@styles/variables'; import CONST from '@src/CONST'; @@ -31,12 +33,14 @@ import type ResponsiveLayoutResult from './types'; export default function useResponsiveLayout(): ResponsiveLayoutResult { const {windowWidth, windowHeight} = useWindowDimensions(); + const isInLandscapeMode = isInLandscapeModeUtil(windowWidth, windowHeight); + // When the soft keyboard opens on mWeb, the window height changes. Use static screen height instead to get real screenHeight. const screenHeight = Dimensions.get('screen').height; const isExtraSmallScreenHeight = screenHeight <= variables.extraSmallMobileResponsiveHeightBreakpoint; - const isSmallScreenWidth = windowWidth <= variables.mobileResponsiveWidthBreakpoint; + const isSmallScreenWidth = windowWidth <= variables.mobileResponsiveWidthBreakpoint || isInLandscapeMode; const isMediumScreenWidth = windowWidth > variables.mobileResponsiveWidthBreakpoint && windowWidth <= variables.tabletResponsiveWidthBreakpoint; - const onboardingIsMediumOrLargerScreenWidth = windowWidth > variables.mobileResponsiveWidthBreakpoint; + const onboardingIsMediumOrLargerScreenWidth = !isInLandscapeMode && windowWidth > variables.mobileResponsiveWidthBreakpoint; const isLargeScreenWidth = windowWidth > variables.tabletResponsiveWidthBreakpoint; const isExtraLargeScreenWidth = windowWidth > variables.sidePanelResponsiveWidthBreakpoint; const isExtraSmallScreenWidth = windowWidth <= variables.extraSmallMobileResponsiveWidthBreakpoint; @@ -66,7 +70,7 @@ export default function useResponsiveLayout(): ResponsiveLayoutResult { // and the component calling this hook is not the child of another modal type, such as a confirm modal (isDisplayedInNarrowModalNavigator && !activeModalType); - const shouldUseNarrowLayout = isSmallScreenWidth || isInNarrowPaneModal; + const shouldUseNarrowLayout = isSmallScreenWidth || isInNarrowPaneModal || isInLandscapeMode; return { shouldUseNarrowLayout, @@ -79,6 +83,6 @@ export default function useResponsiveLayout(): ResponsiveLayoutResult { isLargeScreenWidth, isExtraLargeScreenWidth, isSmallScreen, - isInLandscapeMode: false, + isInLandscapeMode, }; } diff --git a/src/hooks/useSafeAreaPaddings.ts b/src/hooks/useSafeAreaPaddings.ts index 151da9ae061a..3b64e03cd86b 100644 --- a/src/hooks/useSafeAreaPaddings.ts +++ b/src/hooks/useSafeAreaPaddings.ts @@ -35,7 +35,7 @@ import useStyleUtils from './useStyleUtils'; function useSafeAreaPaddings(isUsingEdgeToEdgeBottomSafeAreaPadding = false) { const StyleUtils = useStyleUtils(); const insets = useSafeAreaInsets(); - const {paddingTop, paddingBottom} = useMemo(() => StyleUtils.getPlatformSafeAreaPadding(insets), [StyleUtils, insets]); + const {paddingTop, paddingBottom, paddingLeft, paddingRight} = useMemo(() => StyleUtils.getPlatformSafeAreaPadding(insets), [StyleUtils, insets]); const screenWrapperStatusContext = useContext(ScreenWrapperStatusContext); const isSafeAreaTopPaddingApplied = screenWrapperStatusContext?.isSafeAreaTopPaddingApplied ?? false; @@ -66,9 +66,13 @@ function useSafeAreaPaddings(isUsingEdgeToEdgeBottomSafeAreaPadding = false) { return { paddingTop: isSafeAreaTopPaddingApplied ? 0 : paddingTop, paddingBottom: adaptedPaddingBottom, + paddingLeft, + paddingRight, unmodifiedPaddings: { top: paddingTop, bottom: paddingBottom, + left: paddingLeft, + right: paddingRight, }, insets: adaptedInsets, safeAreaPaddingBottomStyle, diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts b/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts index a1e6e23c1410..aed188ee9233 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts @@ -61,7 +61,9 @@ function useWideModalStackScreenOptions() { contentStyle: styles.navigationScreenCardStyle, }, web: { - cardStyle: styles.navigationScreenCardStyle, + cardStyle: isSmallScreenWidth + ? {...styles.navigationScreenCardStyle, paddingLeft: 'env(safe-area-inset-left)', paddingRight: 'env(safe-area-inset-right)'} + : styles.navigationScreenCardStyle, cardStyleInterpolator, transitionSpec: isSmallScreenWidth ? undefined : RHP_WEB_TRANSITION_SPEC, }, diff --git a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts index 2c678754b464..fc481fa3e219 100644 --- a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts +++ b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts @@ -74,6 +74,8 @@ const useRootNavigatorScreenOptions = () => { top: 0, left: 0, position: 'fixed', + paddingLeft: 'env(safe-area-inset-left)', + paddingRight: 'env(safe-area-inset-right)', }, cardStyleInterpolator: (props: StackCardInterpolationProps) => modalCardStyleInterpolator({props, enter: onboardingEnter}), }, @@ -113,7 +115,9 @@ const useRootNavigatorScreenOptions = () => { animation: Animations.NONE, web: { cardStyleInterpolator: (props: StackCardInterpolationProps) => modalCardStyleInterpolator({props, enter: {kind: 'none'}, applySidePanelOffset: true}), - cardStyle: shouldUseNarrowLayout ? {...StyleUtils.getNavigationModalCardStyle(), paddingLeft: 0} : {...themeStyles.h100, width: '100%'}, + cardStyle: shouldUseNarrowLayout + ? {...StyleUtils.getNavigationModalCardStyle(), paddingLeft: 'env(safe-area-inset-left)', paddingRight: 'env(safe-area-inset-right)'} + : {...themeStyles.h100, width: '100%'}, }, }, } satisfies RootNavigatorScreenOptions; diff --git a/src/libs/Navigation/AppNavigator/useSplitNavigatorScreenOptions.ts b/src/libs/Navigation/AppNavigator/useSplitNavigatorScreenOptions.ts index e375f26b24da..cfecff12d7a9 100644 --- a/src/libs/Navigation/AppNavigator/useSplitNavigatorScreenOptions.ts +++ b/src/libs/Navigation/AppNavigator/useSplitNavigatorScreenOptions.ts @@ -19,6 +19,11 @@ import useModalCardStyleInterpolator from './useModalCardStyleInterpolator'; const IS_MOBILE_SAFARI = isMobileSafari(); +// On mWeb Safari the centralScreen card is `position: fixed`, so `width: 100%` resolves against the viewport +// (including the landscape notch gutters), not the layout parent. Subtract the safe-area +// insets so the card is sized to the usable safe region instead of overflowing. +const NARROW_CARD_SAFE_AREA_WIDTH = 'calc(100% - env(safe-area-inset-left) - env(safe-area-inset-right))'; + type SplitNavigatorScreenOptions = { sidebarScreen: PlatformStackNavigationOptions; centralScreen: PlatformStackNavigationOptions; @@ -66,7 +71,7 @@ const useSplitNavigatorScreenOptions = () => { web: { cardStyleInterpolator: (props: StackCardInterpolationProps) => modalCardStyleInterpolator({props, enter: centralScreenEnter}), cardStyle: shouldUseNarrowLayout - ? StyleUtils.getNavigationModalCardStyle() + ? {...StyleUtils.getNavigationModalCardStyle(), width: NARROW_CARD_SAFE_AREA_WIDTH} : { ...themeStyles.h100, }, diff --git a/src/libs/getIsNarrowLayout/index.ts b/src/libs/getIsNarrowLayout/index.ts index e901f04e7d26..f483b228da22 100644 --- a/src/libs/getIsNarrowLayout/index.ts +++ b/src/libs/getIsNarrowLayout/index.ts @@ -1,5 +1,6 @@ import getIsSmallScreenWidth from '@libs/getIsSmallScreenWidth'; +import isInLandscapeMode from '@libs/isInLandscapeMode'; export default function getIsNarrowLayout() { - return getIsSmallScreenWidth(); + return getIsSmallScreenWidth() || isInLandscapeMode(); } diff --git a/src/libs/isInLandscapeMode/index.ts b/src/libs/isInLandscapeMode/index.ts index b1090972fbd0..358499a8515b 100644 --- a/src/libs/isInLandscapeMode/index.ts +++ b/src/libs/isInLandscapeMode/index.ts @@ -1,7 +1,7 @@ -/** - * We only want to change UI according to the landscape mode on native platforms. - */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -export default function isInLandscapeMode(windowWidth: number, windowHeight: number): boolean { - return false; +import {isMobile} from '@libs/Browser'; + +import {Dimensions} from 'react-native'; + +export default function isInLandscapeMode(windowWidth = Dimensions.get('window').width, windowHeight = Dimensions.get('window').height): boolean { + return isMobile() && windowWidth > windowHeight; } diff --git a/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.tsx b/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.tsx index a1ae718352d9..1937a37f866c 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.tsx @@ -1,6 +1,7 @@ import Button from '@components/ButtonComposed'; import {loadIllustration} from '@components/Icon/IllustrationLoader'; import ImageSVG from '@components/ImageSVG'; +import ScrollView from '@components/ScrollView'; import Text from '@components/Text'; import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails'; @@ -25,26 +26,28 @@ function IOURequestStepDistanceGPS(props: IOURequestStepDistanceGPSProps) { const {translate} = useLocalize(); return ( - - - + + + + + + + {translate('gps.desktop.title')} + {translate('gps.desktop.subtitle')} + + + - - {translate('gps.desktop.title')} - {translate('gps.desktop.subtitle')} - - - - + ); } diff --git a/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx b/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx index 6a0a60695fb6..25ccf04ddbd0 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx @@ -3,6 +3,7 @@ import FormHelpMessage from '@components/FormHelpMessage'; import PressableWithFeedback from '@components/Pressable/PressableWithFeedback'; import ReceiptImage from '@components/ReceiptImage'; import type {AnimatedTextInputRef} from '@components/RNTextInput'; +import ScrollView from '@components/ScrollView'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types'; @@ -608,7 +609,7 @@ function IOURequestStepDistanceOdometer({ shouldShowWrapper={!isCreatingNewRequest} includeSafeAreaPaddingBottom > - + {/* Start Reading */} @@ -745,7 +746,7 @@ function IOURequestStepDistanceOdometer({ sentryLabel={CONST.SENTRY_LABEL.IOU_REQUEST_STEP.DISTANCE_ODOMETER_NEXT_BUTTON} /> - + ); } From 1a187dc9d212a6365bdccaa68a3d8a27cddd5e0d Mon Sep 17 00:00:00 2001 From: GCyganek Date: Thu, 6 Aug 2026 16:18:04 +0200 Subject: [PATCH 02/22] keyboardShouldPersistTaps --- .../iou/request/step/IOURequestStepDistanceOdometer.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx b/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx index 25ccf04ddbd0..1cf632bd55f7 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx @@ -609,7 +609,10 @@ function IOURequestStepDistanceOdometer({ shouldShowWrapper={!isCreatingNewRequest} includeSafeAreaPaddingBottom > - + {/* Start Reading */} From 23ce776bd99c5f64e132fa3b51f3029444ab93f0 Mon Sep 17 00:00:00 2001 From: GCyganek Date: Thu, 6 Aug 2026 16:49:33 +0200 Subject: [PATCH 03/22] Fix isInLandscapeMode mWeb check --- src/libs/isInLandscapeMode/index.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/libs/isInLandscapeMode/index.ts b/src/libs/isInLandscapeMode/index.ts index 358499a8515b..4d8b55253c98 100644 --- a/src/libs/isInLandscapeMode/index.ts +++ b/src/libs/isInLandscapeMode/index.ts @@ -1,7 +1,22 @@ import {isMobile} from '@libs/Browser'; -import {Dimensions} from 'react-native'; +function isInLandscapeMode(): boolean; +function isInLandscapeMode(windowWidth: number, windowHeight: number): boolean; +function isInLandscapeMode(windowWidth?: number, windowHeight?: number): boolean { + if (!isMobile()) { + return false; + } -export default function isInLandscapeMode(windowWidth = Dimensions.get('window').width, windowHeight = Dimensions.get('window').height): boolean { - return isMobile() && windowWidth > windowHeight; + if (windowWidth !== undefined && windowHeight !== undefined) { + return windowWidth > windowHeight; + } + + const orientationType = window.screen?.orientation?.type; + if (orientationType) { + return orientationType.startsWith('landscape'); + } + + return window.innerWidth > window.innerHeight; } + +export default isInLandscapeMode; From a477b6cd8257f62c6f7912791c1a6f2c68e85211 Mon Sep 17 00:00:00 2001 From: GCyganek Date: Fri, 7 Aug 2026 11:05:06 +0200 Subject: [PATCH 04/22] isInLandscapeMode web improvements --- src/hooks/useIsInLandscapeMode/index.ts | 10 ++------ src/hooks/useResponsiveLayout/index.ts | 3 ++- src/libs/isInLandscapeMode/index.ts | 33 ++++++++++++++++--------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/hooks/useIsInLandscapeMode/index.ts b/src/hooks/useIsInLandscapeMode/index.ts index b2b014a18625..b1cd94999fd4 100644 --- a/src/hooks/useIsInLandscapeMode/index.ts +++ b/src/hooks/useIsInLandscapeMode/index.ts @@ -1,15 +1,9 @@ -import useWindowDimensions from '@hooks/useWindowDimensions'; - import isInLandscapeMode from '@libs/isInLandscapeMode'; /** - * Returns whether mWeb is currently in landscape orientation. - * If component already uses useResponsiveLayout, it will return the value from that hook. - * If component already uses useWindowDimensions, use @libs/isInLandscapeMode instead. + * Returns whether device that uses mWeb is currently in landscape orientation. */ function useIsInLandscapeMode(): boolean { - const {windowWidth, windowHeight} = useWindowDimensions(); - - return isInLandscapeMode(windowWidth, windowHeight); + return isInLandscapeMode(); } export default useIsInLandscapeMode; diff --git a/src/hooks/useResponsiveLayout/index.ts b/src/hooks/useResponsiveLayout/index.ts index 882eba412fe7..452e581b7b31 100644 --- a/src/hooks/useResponsiveLayout/index.ts +++ b/src/hooks/useResponsiveLayout/index.ts @@ -2,6 +2,7 @@ import ModalContext from '@components/Modal/ModalContext'; import useWindowDimensions from '@hooks/useWindowDimensions'; +import {isMobile} from '@libs/Browser'; import isInLandscapeModeUtil from '@libs/isInLandscapeMode'; import variables from '@styles/variables'; @@ -33,7 +34,7 @@ import type ResponsiveLayoutResult from './types'; export default function useResponsiveLayout(): ResponsiveLayoutResult { const {windowWidth, windowHeight} = useWindowDimensions(); - const isInLandscapeMode = isInLandscapeModeUtil(windowWidth, windowHeight); + const isInLandscapeMode = isInLandscapeModeUtil(); // When the soft keyboard opens on mWeb, the window height changes. Use static screen height instead to get real screenHeight. const screenHeight = Dimensions.get('screen').height; diff --git a/src/libs/isInLandscapeMode/index.ts b/src/libs/isInLandscapeMode/index.ts index 4d8b55253c98..12a2149d4bd5 100644 --- a/src/libs/isInLandscapeMode/index.ts +++ b/src/libs/isInLandscapeMode/index.ts @@ -1,22 +1,31 @@ import {isMobile} from '@libs/Browser'; -function isInLandscapeMode(): boolean; -function isInLandscapeMode(windowWidth: number, windowHeight: number): boolean; -function isInLandscapeMode(windowWidth?: number, windowHeight?: number): boolean { - if (!isMobile()) { - return false; - } - - if (windowWidth !== undefined && windowHeight !== undefined) { - return windowWidth > windowHeight; - } - +/** + * Returns whether the device is currently in landscape orientation. + */ +function getIsLandscapeOrientation(): boolean { const orientationType = window.screen?.orientation?.type; if (orientationType) { return orientationType.startsWith('landscape'); } - return window.innerWidth > window.innerHeight; + // Legacy iOS Safari (before 16.4) doesn't support the Screen Orientation API. + const legacyOrientation = (window as {orientation?: number}).orientation; + if (typeof legacyOrientation === 'number') { + return Math.abs(legacyOrientation) === 90; + } + + return window.screen.width > window.screen.height; +} + +/** + * The window dimensions are only accepted to keep the signature identical to the native implementation + */ +function isInLandscapeMode(): boolean; +function isInLandscapeMode(windowWidth: number, windowHeight: number): boolean; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function isInLandscapeMode(windowWidth?: number, windowHeight?: number): boolean { + return isMobile() && getIsLandscapeOrientation(); } export default isInLandscapeMode; From 0bfcc9fc553c66cbed058ad887430015cd1b597b Mon Sep 17 00:00:00 2001 From: GCyganek Date: Fri, 7 Aug 2026 11:10:56 +0200 Subject: [PATCH 05/22] isMobile import --- src/hooks/useResponsiveLayout/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hooks/useResponsiveLayout/index.ts b/src/hooks/useResponsiveLayout/index.ts index 452e581b7b31..d21be77224d0 100644 --- a/src/hooks/useResponsiveLayout/index.ts +++ b/src/hooks/useResponsiveLayout/index.ts @@ -2,7 +2,6 @@ import ModalContext from '@components/Modal/ModalContext'; import useWindowDimensions from '@hooks/useWindowDimensions'; -import {isMobile} from '@libs/Browser'; import isInLandscapeModeUtil from '@libs/isInLandscapeMode'; import variables from '@styles/variables'; From 9f87c2753cfe81ecd15265ea842a20fa3d0d356d Mon Sep 17 00:00:00 2001 From: GCyganek Date: Wed, 12 Aug 2026 16:30:54 +0200 Subject: [PATCH 06/22] Listen to orientation changes --- src/hooks/useIsInLandscapeMode/index.ts | 77 ++++++++++++++++++++++++- src/hooks/useResponsiveLayout/index.ts | 2 +- src/libs/isInLandscapeMode/index.ts | 3 +- 3 files changed, 78 insertions(+), 4 deletions(-) diff --git a/src/hooks/useIsInLandscapeMode/index.ts b/src/hooks/useIsInLandscapeMode/index.ts index b1cd94999fd4..9fffd564198d 100644 --- a/src/hooks/useIsInLandscapeMode/index.ts +++ b/src/hooks/useIsInLandscapeMode/index.ts @@ -1,9 +1,82 @@ +import {isMobile as isMobileUtil} from '@libs/Browser'; import isInLandscapeMode from '@libs/isInLandscapeMode'; + +import {useSyncExternalStore} from 'react'; + +const isMobile = isMobileUtil(); +const subscribers = new Set<() => void>(); +let cachedValue = isInLandscapeMode(); +let isListenerAttached = false; + +function handleOrientationChange() { + const nextValue = isInLandscapeMode(); + + if (nextValue === cachedValue) { + return; + } + + cachedValue = nextValue; + for (const callback of subscribers) { + callback(); + } +} + +function addOrientationChangeListener() { + const orientation = window.screen?.orientation; + + if (orientation) { + orientation.addEventListener('change', handleOrientationChange); + return; + } + + window.addEventListener('resize', handleOrientationChange); +} + +function removeOrientationChangeListener() { + const orientation = window.screen?.orientation; + + if (orientation) { + orientation.removeEventListener('change', handleOrientationChange); + return; + } + + window.removeEventListener('resize', handleOrientationChange); +} + +function subscribe(callback: () => void): () => void { + if (!isMobile) { + return () => {}; + } + + subscribers.add(callback); + + if (!isListenerAttached) { + addOrientationChangeListener(); + isListenerAttached = true; + } + + return () => { + subscribers.delete(callback); + + if (subscribers.size > 0) { + return; + } + + removeOrientationChangeListener(); + isListenerAttached = false; + }; +} + +function getSnapshot(): boolean { + return cachedValue; +} + /** - * Returns whether device that uses mWeb is currently in landscape orientation. + * Returns whether device that is currently in landscape orientation. + * It checks whether device is a mobile before subscribing to orientation changes. */ function useIsInLandscapeMode(): boolean { - return isInLandscapeMode(); + return useSyncExternalStore(subscribe, getSnapshot, getSnapshot); } export default useIsInLandscapeMode; diff --git a/src/hooks/useResponsiveLayout/index.ts b/src/hooks/useResponsiveLayout/index.ts index d21be77224d0..882eba412fe7 100644 --- a/src/hooks/useResponsiveLayout/index.ts +++ b/src/hooks/useResponsiveLayout/index.ts @@ -33,7 +33,7 @@ import type ResponsiveLayoutResult from './types'; export default function useResponsiveLayout(): ResponsiveLayoutResult { const {windowWidth, windowHeight} = useWindowDimensions(); - const isInLandscapeMode = isInLandscapeModeUtil(); + const isInLandscapeMode = isInLandscapeModeUtil(windowWidth, windowHeight); // When the soft keyboard opens on mWeb, the window height changes. Use static screen height instead to get real screenHeight. const screenHeight = Dimensions.get('screen').height; diff --git a/src/libs/isInLandscapeMode/index.ts b/src/libs/isInLandscapeMode/index.ts index 12a2149d4bd5..1f2f070c840f 100644 --- a/src/libs/isInLandscapeMode/index.ts +++ b/src/libs/isInLandscapeMode/index.ts @@ -19,7 +19,8 @@ function getIsLandscapeOrientation(): boolean { } /** - * The window dimensions are only accepted to keep the signature identical to the native implementation + * windowWidth and windowHeight should be passed to keep the check reactive (see useResponsiveLayout()). + * Version without params is needed for getIsNarrowLayout() */ function isInLandscapeMode(): boolean; function isInLandscapeMode(windowWidth: number, windowHeight: number): boolean; From 3bb74c245a8dfe6e468cb8c24cfd0dbe19049a48 Mon Sep 17 00:00:00 2001 From: GCyganek Date: Fri, 21 Aug 2026 14:43:19 +0200 Subject: [PATCH 07/22] Fix landscape mode true on tablets --- src/hooks/useIsInLandscapeMode/index.ts | 9 +++++---- src/libs/isInLandscapeMode/index.native.ts | 3 ++- src/libs/isInLandscapeMode/index.ts | 11 ++++++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/hooks/useIsInLandscapeMode/index.ts b/src/hooks/useIsInLandscapeMode/index.ts index 9fffd564198d..89b96dae713f 100644 --- a/src/hooks/useIsInLandscapeMode/index.ts +++ b/src/hooks/useIsInLandscapeMode/index.ts @@ -1,9 +1,10 @@ -import {isMobile as isMobileUtil} from '@libs/Browser'; -import isInLandscapeMode from '@libs/isInLandscapeMode'; +import {isMobile} from '@libs/Browser'; +import isInLandscapeMode, {isTabletScreen} from '@libs/isInLandscapeMode'; import {useSyncExternalStore} from 'react'; -const isMobile = isMobileUtil(); +// Tablets and desktops never report landscape mode, so there is nothing to listen for on them. +const shouldTrackOrientation = isMobile() && !isTabletScreen(); const subscribers = new Set<() => void>(); let cachedValue = isInLandscapeMode(); let isListenerAttached = false; @@ -44,7 +45,7 @@ function removeOrientationChangeListener() { } function subscribe(callback: () => void): () => void { - if (!isMobile) { + if (!shouldTrackOrientation) { return () => {}; } diff --git a/src/libs/isInLandscapeMode/index.native.ts b/src/libs/isInLandscapeMode/index.native.ts index 0a0fb27d3995..e6690c0f8e21 100644 --- a/src/libs/isInLandscapeMode/index.native.ts +++ b/src/libs/isInLandscapeMode/index.native.ts @@ -1,10 +1,11 @@ import DeviceInfo from 'react-native-device-info'; +const isTablet = DeviceInfo.isTablet(); + /** * Returns whether the device is currently in landscape orientation. * Returns false on tablets. */ export default function isInLandscapeMode(windowWidth: number, windowHeight: number): boolean { - const isTablet = DeviceInfo.isTablet(); return !isTablet && windowWidth > windowHeight; } diff --git a/src/libs/isInLandscapeMode/index.ts b/src/libs/isInLandscapeMode/index.ts index 1f2f070c840f..d412a8a33183 100644 --- a/src/libs/isInLandscapeMode/index.ts +++ b/src/libs/isInLandscapeMode/index.ts @@ -1,5 +1,13 @@ import {isMobile} from '@libs/Browser'; +const TABLET_MIN_SCREEN_DIMENSION = 600; + +function isTabletScreen(): boolean { + return Math.min(window.screen.width, window.screen.height) >= TABLET_MIN_SCREEN_DIMENSION; +} + +const isMobilePhoneWeb = isMobile() && !isTabletScreen(); + /** * Returns whether the device is currently in landscape orientation. */ @@ -26,7 +34,8 @@ function isInLandscapeMode(): boolean; function isInLandscapeMode(windowWidth: number, windowHeight: number): boolean; // eslint-disable-next-line @typescript-eslint/no-unused-vars function isInLandscapeMode(windowWidth?: number, windowHeight?: number): boolean { - return isMobile() && getIsLandscapeOrientation(); + return isMobilePhoneWeb && getIsLandscapeOrientation(); } export default isInLandscapeMode; +export {isTabletScreen}; From 17f2adcd81c90e9314314591de4b569b26f7bfc8 Mon Sep 17 00:00:00 2001 From: GCyganek Date: Fri, 21 Aug 2026 15:11:15 +0200 Subject: [PATCH 08/22] Recompute after attach --- src/hooks/useIsInLandscapeMode/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hooks/useIsInLandscapeMode/index.ts b/src/hooks/useIsInLandscapeMode/index.ts index 89b96dae713f..d007c50eada8 100644 --- a/src/hooks/useIsInLandscapeMode/index.ts +++ b/src/hooks/useIsInLandscapeMode/index.ts @@ -54,6 +54,8 @@ function subscribe(callback: () => void): () => void { if (!isListenerAttached) { addOrientationChangeListener(); isListenerAttached = true; + // The orientation can change while nothing is subscribed and no listener is attached, so refresh the cache once we start listening again. + handleOrientationChange(); } return () => { From 6145aca2079ffe6538ae9ad3d455f2652341f3a9 Mon Sep 17 00:00:00 2001 From: GCyganek Date: Mon, 24 Aug 2026 11:11:16 +0200 Subject: [PATCH 09/22] Prioritize usage of isInLandscapeMode from useResponsiveLayout if already in a component --- src/components/CenteredModalLayout/index.tsx | 7 +------ .../EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts | 6 +++--- .../FeatureTrainingContent/FeatureTrainingCarousel.tsx | 7 ++----- .../FeatureTrainingContent/FeatureTrainingContent.tsx | 7 ++----- .../FeatureTrainingContentIllustration.tsx | 6 ++---- src/components/FeatureTrainingModal.tsx | 7 ++----- 6 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/components/CenteredModalLayout/index.tsx b/src/components/CenteredModalLayout/index.tsx index ad213a20e929..82e243c69055 100644 --- a/src/components/CenteredModalLayout/index.tsx +++ b/src/components/CenteredModalLayout/index.tsx @@ -5,9 +5,6 @@ import useBottomSafeSafeAreaPaddingStyle from '@hooks/useBottomSafeSafeAreaPaddi import useKeyboardShortcut from '@hooks/useKeyboardShortcut'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; -import useWindowDimensions from '@hooks/useWindowDimensions'; - -import isInLandscapeModeUtil from '@libs/isInLandscapeMode'; import CONST from '@src/CONST'; @@ -44,10 +41,8 @@ type CenteredModalLayoutProps = { function CenteredModalLayout({children, width, height, onBackdropPress, contentStyle, addBottomSafeAreaPadding = true}: CenteredModalLayoutProps) { const styles = useThemeStyles(); - const {shouldUseNarrowLayout} = useResponsiveLayout(); - const {windowWidth, windowHeight} = useWindowDimensions(); + const {shouldUseNarrowLayout, isInLandscapeMode} = useResponsiveLayout(); - const isInLandscapeMode = isInLandscapeModeUtil(windowWidth, windowHeight); const safeAreaHorizontalPadding = useSafeAreaHorizontalPadding(); const safeAreaStyle = useBottomSafeSafeAreaPaddingStyle({ addBottomSafeAreaPadding: addBottomSafeAreaPadding && !isInLandscapeMode, diff --git a/src/components/EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts b/src/components/EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts index cb3c2901ca9a..0e5d4189d2f2 100644 --- a/src/components/EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts +++ b/src/components/EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts @@ -1,5 +1,6 @@ import emojis from '@assets/emojis'; +import useIsInLandscapeMode from '@hooks/useIsInLandscapeMode'; import useKeyboardState from '@hooks/useKeyboardState'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; @@ -10,7 +11,6 @@ import useWindowDimensions from '@hooks/useWindowDimensions'; import type {EmojiPickerList, EmojiPickerListItem} from '@libs/EmojiUtils'; import {getHeaderEmojis, getSpacersIndexes, mergeEmojisWithFrequentlyUsedEmojis, processFrequentlyUsedEmojis, suggestEmojis} from '@libs/EmojiUtils'; -import isInLandscapeModeUtil from '@libs/isInLandscapeMode'; import ONYXKEYS from '@src/ONYXKEYS'; import calculateModalHeightInLandscapeMode from '@src/utils/calculateModalHeightInLandscapeMode'; @@ -32,10 +32,10 @@ const useEmojiPickerMenu = () => { const isListFiltered = allEmojis.length !== filteredEmojis.length; const {preferredLocale} = useLocalize(); const [preferredSkinTone] = usePreferredEmojiSkinTone(); - const {windowHeight, windowWidth} = useWindowDimensions(); + const {windowHeight} = useWindowDimensions(); const StyleUtils = useStyleUtils(); const {keyboardActiveHeight} = useKeyboardState(); - const isInLandscapeMode = isInLandscapeModeUtil(windowWidth, windowHeight); + const isInLandscapeMode = useIsInLandscapeMode(); const {top: topSafeAreaInset} = useSafeAreaInsets(); /** diff --git a/src/components/FeatureTrainingContent/FeatureTrainingCarousel.tsx b/src/components/FeatureTrainingContent/FeatureTrainingCarousel.tsx index e07ed12ea63f..87b95643160c 100644 --- a/src/components/FeatureTrainingContent/FeatureTrainingCarousel.tsx +++ b/src/components/FeatureTrainingContent/FeatureTrainingCarousel.tsx @@ -13,8 +13,6 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; -import isInLandscapeModeUtil from '@libs/isInLandscapeMode'; - import variables from '@styles/variables'; import CONST from '@src/CONST'; @@ -66,11 +64,10 @@ function FeatureTrainingCarousel({ const theme = useTheme(); const {translate} = useLocalize(); const expensifyIcons = useMemoizedLazyExpensifyIcons(['Close']); - const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout(); - const {windowHeight, windowWidth} = useWindowDimensions(); + const {onboardingIsMediumOrLargerScreenWidth, isInLandscapeMode} = useResponsiveLayout(); + const {windowHeight} = useWindowDimensions(); const insets = useSafeAreaInsets(); const {isKeyboardActive} = useKeyboardState(); - const isInLandscapeMode = isInLandscapeModeUtil(windowWidth, windowHeight); const [currentPage, setCurrentPage] = useState(0); const [carouselViewportWidth, setCarouselViewportWidth] = useState(0); diff --git a/src/components/FeatureTrainingContent/FeatureTrainingContent.tsx b/src/components/FeatureTrainingContent/FeatureTrainingContent.tsx index 792e4e070372..5edb42e54e8a 100644 --- a/src/components/FeatureTrainingContent/FeatureTrainingContent.tsx +++ b/src/components/FeatureTrainingContent/FeatureTrainingContent.tsx @@ -7,8 +7,6 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; -import isInLandscapeModeUtil from '@libs/isInLandscapeMode'; - import variables from '@styles/variables'; import CONST from '@src/CONST'; @@ -52,15 +50,14 @@ function FeatureTrainingContent({ }: FeatureTrainingContentProps) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); - const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout(); - const {windowHeight, windowWidth} = useWindowDimensions(); + const {onboardingIsMediumOrLargerScreenWidth, isInLandscapeMode} = useResponsiveLayout(); + const {windowHeight} = useWindowDimensions(); const [willShowAgain, setWillShowAgain] = useState(true); const scrollViewRef = useRef(null); const [containerHeight, setContainerHeight] = useState(0); const [contentHeight, setContentHeight] = useState(0); const insets = useSafeAreaInsets(); const {isKeyboardActive} = useKeyboardState(); - const isInLandscapeMode = isInLandscapeModeUtil(windowWidth, windowHeight); const shouldUseScrollView = shouldUseScrollViewProp || isInLandscapeMode; diff --git a/src/components/FeatureTrainingContent/FeatureTrainingContentIllustration.tsx b/src/components/FeatureTrainingContent/FeatureTrainingContentIllustration.tsx index 0716dca3987f..aae5256961d4 100644 --- a/src/components/FeatureTrainingContent/FeatureTrainingContentIllustration.tsx +++ b/src/components/FeatureTrainingContent/FeatureTrainingContentIllustration.tsx @@ -11,7 +11,6 @@ import useWindowDimensions from '@hooks/useWindowDimensions'; import Accessibility from '@libs/Accessibility'; import {isMobile} from '@libs/Browser'; -import isInLandscapeModeUtil from '@libs/isInLandscapeMode'; import {getIsOffline} from '@libs/NetworkState'; import variables from '@styles/variables'; @@ -76,11 +75,10 @@ function FeatureTrainingContentIllustration({ const styles = useThemeStyles(); const isReduceMotionEnabled = Accessibility.useReducedMotion(); const illustrations = useMemoizedLazyIllustrations(['Hands']); - const {onboardingIsMediumOrLargerScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout(); + const {onboardingIsMediumOrLargerScreenWidth, shouldUseNarrowLayout, isInLandscapeMode} = useResponsiveLayout(); const videoStatus = useVideoStatus(); - const {windowHeight, windowWidth} = useWindowDimensions(); + const {windowHeight} = useWindowDimensions(); const [illustrationAspectRatio, setIllustrationAspectRatio] = useState(illustrationAspectRatioProp ?? VIDEO_ASPECT_RATIO); - const isInLandscapeMode = isInLandscapeModeUtil(windowWidth, windowHeight); const animationRef = useRef(null); useEffect(() => { diff --git a/src/components/FeatureTrainingModal.tsx b/src/components/FeatureTrainingModal.tsx index 93a76defce17..9f2d1df31cd0 100644 --- a/src/components/FeatureTrainingModal.tsx +++ b/src/components/FeatureTrainingModal.tsx @@ -1,8 +1,6 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; -import useWindowDimensions from '@hooks/useWindowDimensions'; -import isInLandscapeModeUtil from '@libs/isInLandscapeMode'; import Log from '@libs/Log'; import TransitionTracker from '@libs/Navigation/TransitionTracker'; @@ -28,9 +26,8 @@ type FeatureTrainingModalProps = FeatureTrainingContentProps & { function FeatureTrainingModal({modalInnerContainerStyle, onConfirm, onClose, shouldUseScrollView: shouldUseScrollViewProp = false, ...contentProps}: FeatureTrainingModalProps) { const styles = useThemeStyles(); - const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout(); - const {windowWidth, windowHeight} = useWindowDimensions(); - const shouldUseScrollView = shouldUseScrollViewProp || isInLandscapeModeUtil(windowWidth, windowHeight); + const {onboardingIsMediumOrLargerScreenWidth, isInLandscapeMode} = useResponsiveLayout(); + const shouldUseScrollView = shouldUseScrollViewProp || isInLandscapeMode; const [isModalVisible, setIsModalVisible] = useState(false); const pendingCloseRef = useRef(false); From 50e34acb402b4982daa7d3a61e151cc5ad27943b Mon Sep 17 00:00:00 2001 From: GCyganek Date: Mon, 24 Aug 2026 12:38:09 +0200 Subject: [PATCH 10/22] Fix layout flickers on orientation changes --- .../useIsInLandscapeMode/index.native.ts | 16 ---- src/hooks/useIsInLandscapeMode/index.ts | 85 ++----------------- src/libs/isInLandscapeMode/index.ts | 37 ++++---- 3 files changed, 24 insertions(+), 114 deletions(-) delete mode 100644 src/hooks/useIsInLandscapeMode/index.native.ts diff --git a/src/hooks/useIsInLandscapeMode/index.native.ts b/src/hooks/useIsInLandscapeMode/index.native.ts deleted file mode 100644 index 0f36e84fdade..000000000000 --- a/src/hooks/useIsInLandscapeMode/index.native.ts +++ /dev/null @@ -1,16 +0,0 @@ -import useWindowDimensions from '@hooks/useWindowDimensions'; - -import isInLandscapeMode from '@libs/isInLandscapeMode'; - -/** - * Returns whether the device is currently in landscape orientation. - * If component already uses useResponsiveLayout, it will return the value from that hook. - * If component already uses useWindowDimensions, use @libs/isInLandscapeMode instead. - */ -function useIsInLandscapeMode(): boolean { - const {windowWidth, windowHeight} = useWindowDimensions(); - - return isInLandscapeMode(windowWidth, windowHeight); -} - -export default useIsInLandscapeMode; diff --git a/src/hooks/useIsInLandscapeMode/index.ts b/src/hooks/useIsInLandscapeMode/index.ts index d007c50eada8..0f36e84fdade 100644 --- a/src/hooks/useIsInLandscapeMode/index.ts +++ b/src/hooks/useIsInLandscapeMode/index.ts @@ -1,85 +1,16 @@ -import {isMobile} from '@libs/Browser'; -import isInLandscapeMode, {isTabletScreen} from '@libs/isInLandscapeMode'; +import useWindowDimensions from '@hooks/useWindowDimensions'; -import {useSyncExternalStore} from 'react'; - -// Tablets and desktops never report landscape mode, so there is nothing to listen for on them. -const shouldTrackOrientation = isMobile() && !isTabletScreen(); -const subscribers = new Set<() => void>(); -let cachedValue = isInLandscapeMode(); -let isListenerAttached = false; - -function handleOrientationChange() { - const nextValue = isInLandscapeMode(); - - if (nextValue === cachedValue) { - return; - } - - cachedValue = nextValue; - for (const callback of subscribers) { - callback(); - } -} - -function addOrientationChangeListener() { - const orientation = window.screen?.orientation; - - if (orientation) { - orientation.addEventListener('change', handleOrientationChange); - return; - } - - window.addEventListener('resize', handleOrientationChange); -} - -function removeOrientationChangeListener() { - const orientation = window.screen?.orientation; - - if (orientation) { - orientation.removeEventListener('change', handleOrientationChange); - return; - } - - window.removeEventListener('resize', handleOrientationChange); -} - -function subscribe(callback: () => void): () => void { - if (!shouldTrackOrientation) { - return () => {}; - } - - subscribers.add(callback); - - if (!isListenerAttached) { - addOrientationChangeListener(); - isListenerAttached = true; - // The orientation can change while nothing is subscribed and no listener is attached, so refresh the cache once we start listening again. - handleOrientationChange(); - } - - return () => { - subscribers.delete(callback); - - if (subscribers.size > 0) { - return; - } - - removeOrientationChangeListener(); - isListenerAttached = false; - }; -} - -function getSnapshot(): boolean { - return cachedValue; -} +import isInLandscapeMode from '@libs/isInLandscapeMode'; /** - * Returns whether device that is currently in landscape orientation. - * It checks whether device is a mobile before subscribing to orientation changes. + * Returns whether the device is currently in landscape orientation. + * If component already uses useResponsiveLayout, it will return the value from that hook. + * If component already uses useWindowDimensions, use @libs/isInLandscapeMode instead. */ function useIsInLandscapeMode(): boolean { - return useSyncExternalStore(subscribe, getSnapshot, getSnapshot); + const {windowWidth, windowHeight} = useWindowDimensions(); + + return isInLandscapeMode(windowWidth, windowHeight); } export default useIsInLandscapeMode; diff --git a/src/libs/isInLandscapeMode/index.ts b/src/libs/isInLandscapeMode/index.ts index d412a8a33183..6b2c478fabea 100644 --- a/src/libs/isInLandscapeMode/index.ts +++ b/src/libs/isInLandscapeMode/index.ts @@ -8,33 +8,28 @@ function isTabletScreen(): boolean { const isMobilePhoneWeb = isMobile() && !isTabletScreen(); -/** - * Returns whether the device is currently in landscape orientation. - */ -function getIsLandscapeOrientation(): boolean { - const orientationType = window.screen?.orientation?.type; - if (orientationType) { - return orientationType.startsWith('landscape'); - } - - // Legacy iOS Safari (before 16.4) doesn't support the Screen Orientation API. - const legacyOrientation = (window as {orientation?: number}).orientation; - if (typeof legacyOrientation === 'number') { - return Math.abs(legacyOrientation) === 90; - } +const screenShortSide = Math.min(window.screen.width, window.screen.height); +const screenLongSide = Math.max(window.screen.width, window.screen.height); - return window.screen.width > window.screen.height; +function getViewportWidth(): number { + return window.visualViewport?.width ?? window.innerWidth; } /** - * windowWidth and windowHeight should be passed to keep the check reactive (see useResponsiveLayout()). - * Version without params is needed for getIsNarrowLayout() + * Returns whether the device is currently in landscape orientation. Returns false on tablets and non-mobile browsers. + * Derived from the width instead of the Screen Orientation API (its `change` event lands in a different task than + * `resize`, causing a flicker) and instead of the height (the soft keyboard shrinks height). */ -function isInLandscapeMode(): boolean; -function isInLandscapeMode(windowWidth: number, windowHeight: number): boolean; // eslint-disable-next-line @typescript-eslint/no-unused-vars -function isInLandscapeMode(windowWidth?: number, windowHeight?: number): boolean { - return isMobilePhoneWeb && getIsLandscapeOrientation(); +function isInLandscapeMode(windowWidth: number = getViewportWidth(), windowHeight?: number): boolean { + if (!isMobilePhoneWeb) { + return false; + } + + const distanceToLongSide = Math.abs(windowWidth - screenLongSide); + const distanceToShortSide = Math.abs(windowWidth - screenShortSide); + + return distanceToLongSide < distanceToShortSide; } export default isInLandscapeMode; From 0ab7037dea5c3cec147f3dd9b844c0f1382d234d Mon Sep 17 00:00:00 2001 From: GCyganek Date: Mon, 24 Aug 2026 12:53:55 +0200 Subject: [PATCH 11/22] Fix knip check --- src/libs/isInLandscapeMode/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/isInLandscapeMode/index.ts b/src/libs/isInLandscapeMode/index.ts index 6b2c478fabea..75fcb925d3b5 100644 --- a/src/libs/isInLandscapeMode/index.ts +++ b/src/libs/isInLandscapeMode/index.ts @@ -33,4 +33,3 @@ function isInLandscapeMode(windowWidth: number = getViewportWidth(), windowHeigh } export default isInLandscapeMode; -export {isTabletScreen}; From 908f7f7403c40786f505c5be70ea122d1dc5487d Mon Sep 17 00:00:00 2001 From: GCyganek Date: Mon, 24 Aug 2026 14:00:16 +0200 Subject: [PATCH 12/22] useEmojiPickerMenu use isLandscapeMenu util --- .../EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts b/src/components/EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts index 0e5d4189d2f2..cb3c2901ca9a 100644 --- a/src/components/EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts +++ b/src/components/EmojiPicker/EmojiPickerMenu/useEmojiPickerMenu.ts @@ -1,6 +1,5 @@ import emojis from '@assets/emojis'; -import useIsInLandscapeMode from '@hooks/useIsInLandscapeMode'; import useKeyboardState from '@hooks/useKeyboardState'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; @@ -11,6 +10,7 @@ import useWindowDimensions from '@hooks/useWindowDimensions'; import type {EmojiPickerList, EmojiPickerListItem} from '@libs/EmojiUtils'; import {getHeaderEmojis, getSpacersIndexes, mergeEmojisWithFrequentlyUsedEmojis, processFrequentlyUsedEmojis, suggestEmojis} from '@libs/EmojiUtils'; +import isInLandscapeModeUtil from '@libs/isInLandscapeMode'; import ONYXKEYS from '@src/ONYXKEYS'; import calculateModalHeightInLandscapeMode from '@src/utils/calculateModalHeightInLandscapeMode'; @@ -32,10 +32,10 @@ const useEmojiPickerMenu = () => { const isListFiltered = allEmojis.length !== filteredEmojis.length; const {preferredLocale} = useLocalize(); const [preferredSkinTone] = usePreferredEmojiSkinTone(); - const {windowHeight} = useWindowDimensions(); + const {windowHeight, windowWidth} = useWindowDimensions(); const StyleUtils = useStyleUtils(); const {keyboardActiveHeight} = useKeyboardState(); - const isInLandscapeMode = useIsInLandscapeMode(); + const isInLandscapeMode = isInLandscapeModeUtil(windowWidth, windowHeight); const {top: topSafeAreaInset} = useSafeAreaInsets(); /** From f1f2fa96e4733c065f13785830ead477d029d7fa Mon Sep 17 00:00:00 2001 From: GCyganek Date: Tue, 25 Aug 2026 13:28:14 +0200 Subject: [PATCH 13/22] Fix crashes on iOS safari mWeb when rotating to landscape with open keyboard on Sign In page --- src/hooks/useViewportOffsetTop/index.ts | 28 ++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/hooks/useViewportOffsetTop/index.ts b/src/hooks/useViewportOffsetTop/index.ts index 00c768977e53..ed71610b0439 100644 --- a/src/hooks/useViewportOffsetTop/index.ts +++ b/src/hooks/useViewportOffsetTop/index.ts @@ -2,16 +2,30 @@ import addViewportResizeListener from '@libs/VisualViewport'; import {useSyncExternalStore} from 'react'; -/** - * A hook that returns the offset of the top edge of the visual viewport - */ +function getVisualViewportOffsetTop() { + return window.visualViewport?.offsetTop ?? 0; +} + +let offsetTop = getVisualViewportOffsetTop(); + function subscribe(callback: () => void) { - const unsubscribe = addViewportResizeListener(callback); - window.visualViewport?.addEventListener('scroll', callback); + offsetTop = getVisualViewportOffsetTop(); + + const handleViewportChange = () => { + offsetTop = getVisualViewportOffsetTop(); + callback(); + }; + + const unsubscribe = addViewportResizeListener(handleViewportChange); + window.visualViewport?.addEventListener('scroll', handleViewportChange); return () => { - window.visualViewport?.removeEventListener('scroll', callback); + window.visualViewport?.removeEventListener('scroll', handleViewportChange); unsubscribe(); }; } -export default () => useSyncExternalStore(subscribe, () => window.visualViewport?.offsetTop ?? 0); +function getSnapshot() { + return offsetTop; +} + +export default () => useSyncExternalStore(subscribe, getSnapshot); From a48c9777efac1c9bbf173081fc075f923e9a812e Mon Sep 17 00:00:00 2001 From: GCyganek Date: Tue, 25 Aug 2026 14:03:55 +0200 Subject: [PATCH 14/22] Fix isMediumScreenWidth check in landscapem ode --- src/hooks/useResponsiveLayout/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hooks/useResponsiveLayout/index.ts b/src/hooks/useResponsiveLayout/index.ts index 882eba412fe7..09f8c08f3e15 100644 --- a/src/hooks/useResponsiveLayout/index.ts +++ b/src/hooks/useResponsiveLayout/index.ts @@ -39,7 +39,8 @@ export default function useResponsiveLayout(): ResponsiveLayoutResult { const screenHeight = Dimensions.get('screen').height; const isExtraSmallScreenHeight = screenHeight <= variables.extraSmallMobileResponsiveHeightBreakpoint; const isSmallScreenWidth = windowWidth <= variables.mobileResponsiveWidthBreakpoint || isInLandscapeMode; - const isMediumScreenWidth = windowWidth > variables.mobileResponsiveWidthBreakpoint && windowWidth <= variables.tabletResponsiveWidthBreakpoint; + const isMediumScreenWidth = windowWidth > variables.mobileResponsiveWidthBreakpoint && windowWidth <= variables.tabletResponsiveWidthBreakpoint && !isInLandscapeMode; + console.log({isMediumScreenWidth, isSmallScreenWidth, isInLandscapeMode}); const onboardingIsMediumOrLargerScreenWidth = !isInLandscapeMode && windowWidth > variables.mobileResponsiveWidthBreakpoint; const isLargeScreenWidth = windowWidth > variables.tabletResponsiveWidthBreakpoint; const isExtraLargeScreenWidth = windowWidth > variables.sidePanelResponsiveWidthBreakpoint; From ae9ccbad8a5051a6d5ab89e0bae8853e19beab3a Mon Sep 17 00:00:00 2001 From: GCyganek Date: Tue, 25 Aug 2026 15:32:16 +0200 Subject: [PATCH 15/22] delete console.log --- src/hooks/useResponsiveLayout/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hooks/useResponsiveLayout/index.ts b/src/hooks/useResponsiveLayout/index.ts index 09f8c08f3e15..4e70134a455d 100644 --- a/src/hooks/useResponsiveLayout/index.ts +++ b/src/hooks/useResponsiveLayout/index.ts @@ -40,7 +40,6 @@ export default function useResponsiveLayout(): ResponsiveLayoutResult { const isExtraSmallScreenHeight = screenHeight <= variables.extraSmallMobileResponsiveHeightBreakpoint; const isSmallScreenWidth = windowWidth <= variables.mobileResponsiveWidthBreakpoint || isInLandscapeMode; const isMediumScreenWidth = windowWidth > variables.mobileResponsiveWidthBreakpoint && windowWidth <= variables.tabletResponsiveWidthBreakpoint && !isInLandscapeMode; - console.log({isMediumScreenWidth, isSmallScreenWidth, isInLandscapeMode}); const onboardingIsMediumOrLargerScreenWidth = !isInLandscapeMode && windowWidth > variables.mobileResponsiveWidthBreakpoint; const isLargeScreenWidth = windowWidth > variables.tabletResponsiveWidthBreakpoint; const isExtraLargeScreenWidth = windowWidth > variables.sidePanelResponsiveWidthBreakpoint; From e590bc2e837e0bc0568594479cc930781b60d2a9 Mon Sep 17 00:00:00 2001 From: GCyganek Date: Wed, 26 Aug 2026 13:54:19 +0200 Subject: [PATCH 16/22] Use the same default as getIsNarrowLayout() --- src/libs/isInLandscapeMode/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/isInLandscapeMode/index.ts b/src/libs/isInLandscapeMode/index.ts index 75fcb925d3b5..8af37386def8 100644 --- a/src/libs/isInLandscapeMode/index.ts +++ b/src/libs/isInLandscapeMode/index.ts @@ -1,5 +1,7 @@ import {isMobile} from '@libs/Browser'; +import {Dimensions} from 'react-native'; + const TABLET_MIN_SCREEN_DIMENSION = 600; function isTabletScreen(): boolean { @@ -12,7 +14,7 @@ const screenShortSide = Math.min(window.screen.width, window.screen.height); const screenLongSide = Math.max(window.screen.width, window.screen.height); function getViewportWidth(): number { - return window.visualViewport?.width ?? window.innerWidth; + return Dimensions.get('window').width; } /** From 17c07e9ac021e675332ac1471f9277c79895aabe Mon Sep 17 00:00:00 2001 From: GCyganek Date: Wed, 26 Aug 2026 16:26:06 +0200 Subject: [PATCH 17/22] Fix Save view screen safe area iOS Safari --- .../Navigators/RightModalNavigator.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index e44e3646c3fd..290748f862df 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -27,7 +27,7 @@ import calculateSuperWideRHPWidth from '@libs/Navigation/helpers/calculateSuperW import {isFullScreenName} from '@libs/Navigation/helpers/isNavigatorName'; import Navigation, {navigationRef} from '@libs/Navigation/Navigation'; import Animations from '@libs/Navigation/PlatformStackNavigation/navigationOptions/animation'; -import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; +import type {PlatformStackNavigationOptions, PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import TransitionTracker from '@libs/Navigation/TransitionTracker'; import createRightModalNavigator from '@navigation/AppNavigator/createRightModalNavigator'; @@ -206,6 +206,17 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { } as const; }, [animatedWidth, shouldUseNarrowLayout]); + const searchSaveScreenOptions = useMemo( + () => ({ + web: { + cardStyle: isSmallScreenWidth + ? {...styles.navigationScreenCardStyle, paddingLeft: 'env(safe-area-inset-left)', paddingRight: 'env(safe-area-inset-right)'} + : styles.navigationScreenCardStyle, + }, + }), + [isSmallScreenWidth, styles.navigationScreenCardStyle], + ); + const overlayPositionLeft = useMemo(() => -1 * calculateSuperWideRHPWidth(windowWidth), [windowWidth]); const screenListeners = useMemo( @@ -465,6 +476,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { Date: Fri, 28 Aug 2026 11:24:56 +0200 Subject: [PATCH 18/22] useScrollableWrapper --- .../FeatureTraining/hooks/useScrollableWrapper.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/components/FeatureTraining/hooks/useScrollableWrapper.ts b/src/components/FeatureTraining/hooks/useScrollableWrapper.ts index bfff2ca6ac05..0db8e9515389 100644 --- a/src/components/FeatureTraining/hooks/useScrollableWrapper.ts +++ b/src/components/FeatureTraining/hooks/useScrollableWrapper.ts @@ -7,8 +7,6 @@ import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; -import isInLandscapeModeUtil from '@libs/isInLandscapeMode'; - import CONST from '@src/CONST'; // eslint-disable-next-line no-restricted-imports -- type-only import from react-native @@ -25,12 +23,11 @@ type UseScrollableWrapperOptions = { function useScrollableWrapper({shouldUseScrollView: shouldUseScrollViewProp = false, width}: UseScrollableWrapperOptions) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); - const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout(); - const {windowHeight, windowWidth} = useWindowDimensions(); + const {onboardingIsMediumOrLargerScreenWidth, isInLandscapeMode} = useResponsiveLayout(); + const {windowHeight} = useWindowDimensions(); const insets = useSafeAreaInsets(); const {isKeyboardActive} = useKeyboardState(); - const isInLandscapeMode = isInLandscapeModeUtil(windowWidth, windowHeight); const shouldUseScrollView = shouldUseScrollViewProp || isInLandscapeMode; const scrollViewRef = useRef(null); From 4a610aa618a88ead599b47852479fa6cf1bd15fd Mon Sep 17 00:00:00 2001 From: GCyganek Date: Tue, 1 Sep 2026 12:04:36 +0200 Subject: [PATCH 19/22] Fix GPS; shouldUseNarrowLayout do not check isInLandscapeMode --- src/hooks/useResponsiveLayout/index.ts | 2 +- src/pages/iou/request/step/IOURequestStepDistanceGPS/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/useResponsiveLayout/index.ts b/src/hooks/useResponsiveLayout/index.ts index 4e70134a455d..0486cd295b94 100644 --- a/src/hooks/useResponsiveLayout/index.ts +++ b/src/hooks/useResponsiveLayout/index.ts @@ -70,7 +70,7 @@ export default function useResponsiveLayout(): ResponsiveLayoutResult { // and the component calling this hook is not the child of another modal type, such as a confirm modal (isDisplayedInNarrowModalNavigator && !activeModalType); - const shouldUseNarrowLayout = isSmallScreenWidth || isInNarrowPaneModal || isInLandscapeMode; + const shouldUseNarrowLayout = isSmallScreenWidth || isInNarrowPaneModal; return { shouldUseNarrowLayout, diff --git a/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.tsx b/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.tsx index 1937a37f866c..5dc10bd44255 100644 --- a/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistanceGPS/index.tsx @@ -27,7 +27,7 @@ function IOURequestStepDistanceGPS(props: IOURequestStepDistanceGPSProps) { return ( - + Date: Tue, 1 Sep 2026 12:13:45 +0200 Subject: [PATCH 20/22] getStyleWithEnvSafeAreaPadding() --- .../ModalStackNavigators/useModalStackScreenOptions.ts | 9 +++++---- .../AppNavigator/Navigators/RightModalNavigator.tsx | 8 ++++---- .../AppNavigator/useRootNavigatorScreenOptions.ts | 4 +--- src/styles/utils/index.ts | 6 ++++++ 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts b/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts index 753404613426..43b37502d3fc 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/useModalStackScreenOptions.ts @@ -2,6 +2,7 @@ import {animatedSuperWideRHPWidth, useWideRHPState} from '@components/WideRHPCon import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useSidePanelState from '@hooks/useSidePanelState'; +import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import enhanceCardStyleInterpolator from '@libs/Navigation/AppNavigator/enhanceCardStyleInterpolator'; @@ -23,6 +24,8 @@ import {Animated} from 'react-native'; function useWideModalStackScreenOptions() { const styles = useThemeStyles(); + const StyleUtils = useStyleUtils(); + const modalCardStyleInterpolator = useModalCardStyleInterpolator(); // We have to use isSmallScreenWidth, otherwise the content of RHP 'jumps' on Safari - its width is set to size of screen and only after rerender it is set to the correct value @@ -68,15 +71,13 @@ function useWideModalStackScreenOptions() { contentStyle: styles.navigationScreenCardStyle, }, web: { - cardStyle: isSmallScreenWidth - ? {...styles.navigationScreenCardStyle, paddingLeft: 'env(safe-area-inset-left)', paddingRight: 'env(safe-area-inset-right)'} - : styles.navigationScreenCardStyle, + cardStyle: isSmallScreenWidth ? StyleUtils.getStyleWithEnvSafeAreaPadding(styles.navigationScreenCardStyle) : styles.navigationScreenCardStyle, cardStyleInterpolator, transitionSpec: isSmallScreenWidth ? undefined : RHP_WEB_TRANSITION_SPEC, }, }; }, - [isSmallScreenWidth, modalCardStyleInterpolator, sidePanelOffset, styles, superWideRHPRouteKeys, wideRHPRouteKeys], + [StyleUtils, isSmallScreenWidth, modalCardStyleInterpolator, sidePanelOffset, styles, superWideRHPRouteKeys, wideRHPRouteKeys], ); } diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index c9fe7e6509d7..ff6be85829cc 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -13,6 +13,7 @@ import { import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useSidePanelState from '@hooks/useSidePanelState'; +import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; @@ -173,6 +174,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { const {windowWidth} = useWindowDimensions(); const modalStackScreenOptions = useModalStackScreenOptions(); const styles = useThemeStyles(); + const StyleUtils = useStyleUtils(); const {sidePanelOffset} = useSidePanelState(); // When a fullscreen route is pre-inserted under the RHP, disable the slide-out animation @@ -220,12 +222,10 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { const searchSaveScreenOptions = useMemo( () => ({ web: { - cardStyle: isSmallScreenWidth - ? {...styles.navigationScreenCardStyle, paddingLeft: 'env(safe-area-inset-left)', paddingRight: 'env(safe-area-inset-right)'} - : styles.navigationScreenCardStyle, + cardStyle: isSmallScreenWidth ? StyleUtils.getStyleWithEnvSafeAreaPadding(styles.navigationScreenCardStyle) : styles.navigationScreenCardStyle, }, }), - [isSmallScreenWidth, styles.navigationScreenCardStyle], + [StyleUtils, isSmallScreenWidth, styles.navigationScreenCardStyle], ); const overlayPositionLeft = useMemo(() => -1 * calculateSuperWideRHPWidth(windowWidth), [windowWidth]); diff --git a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts index fc481fa3e219..1bf7bad237a5 100644 --- a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts +++ b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts @@ -115,9 +115,7 @@ const useRootNavigatorScreenOptions = () => { animation: Animations.NONE, web: { cardStyleInterpolator: (props: StackCardInterpolationProps) => modalCardStyleInterpolator({props, enter: {kind: 'none'}, applySidePanelOffset: true}), - cardStyle: shouldUseNarrowLayout - ? {...StyleUtils.getNavigationModalCardStyle(), paddingLeft: 'env(safe-area-inset-left)', paddingRight: 'env(safe-area-inset-right)'} - : {...themeStyles.h100, width: '100%'}, + cardStyle: shouldUseNarrowLayout ? StyleUtils.getStyleWithEnvSafeAreaPadding(StyleUtils.getNavigationModalCardStyle()) : {...themeStyles.h100, width: '100%'}, }, }, } satisfies RootNavigatorScreenOptions; diff --git a/src/styles/utils/index.ts b/src/styles/utils/index.ts index 489bafa8dfa1..525810bb8f5d 100644 --- a/src/styles/utils/index.ts +++ b/src/styles/utils/index.ts @@ -2460,6 +2460,12 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({ paddingBottom: safeAreaPaddingBottom, backgroundColor: theme.appBG, }), + + getStyleWithEnvSafeAreaPadding: (style: ViewStyle): ViewStyle => ({ + ...style, + paddingLeft: 'env(safe-area-inset-left)', + paddingRight: 'env(safe-area-inset-right)', + }), }); type StyleUtilsType = ReturnType; From 4a96104c101c3886729f8383efe66cd9d6ff99fe Mon Sep 17 00:00:00 2001 From: GCyganek Date: Tue, 1 Sep 2026 12:44:37 +0200 Subject: [PATCH 21/22] SearchSavePage options --- .../Navigators/RightModalNavigator.tsx | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx index ff6be85829cc..c10ea1ea7d30 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/RightModalNavigator.tsx @@ -13,7 +13,6 @@ import { import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useSidePanelState from '@hooks/useSidePanelState'; -import useStyleUtils from '@hooks/useStyleUtils'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; @@ -28,7 +27,7 @@ import calculateSuperWideRHPWidth from '@libs/Navigation/helpers/calculateSuperW import {isFullScreenName} from '@libs/Navigation/helpers/isNavigatorName'; import Navigation, {navigationRef} from '@libs/Navigation/Navigation'; import Animations from '@libs/Navigation/PlatformStackNavigation/navigationOptions/animation'; -import type {PlatformStackNavigationOptions, PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; +import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import TransitionTracker from '@libs/Navigation/TransitionTracker'; import createRightModalNavigator from '@navigation/AppNavigator/createRightModalNavigator'; @@ -174,7 +173,6 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { const {windowWidth} = useWindowDimensions(); const modalStackScreenOptions = useModalStackScreenOptions(); const styles = useThemeStyles(); - const StyleUtils = useStyleUtils(); const {sidePanelOffset} = useSidePanelState(); // When a fullscreen route is pre-inserted under the RHP, disable the slide-out animation @@ -219,15 +217,6 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { } as const; }, [animatedWidth, shouldUseNarrowLayout]); - const searchSaveScreenOptions = useMemo( - () => ({ - web: { - cardStyle: isSmallScreenWidth ? StyleUtils.getStyleWithEnvSafeAreaPadding(styles.navigationScreenCardStyle) : styles.navigationScreenCardStyle, - }, - }), - [StyleUtils, isSmallScreenWidth, styles.navigationScreenCardStyle], - ); - const overlayPositionLeft = useMemo(() => -1 * calculateSuperWideRHPWidth(windowWidth), [windowWidth]); const screenListeners = useMemo( @@ -487,7 +476,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) { Date: Tue, 1 Sep 2026 13:14:02 +0200 Subject: [PATCH 22/22] Fix Workspace screens having double safe area paddings --- .../AppNavigator/useSplitNavigatorScreenOptions.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/useSplitNavigatorScreenOptions.ts b/src/libs/Navigation/AppNavigator/useSplitNavigatorScreenOptions.ts index cfecff12d7a9..160f3b11504e 100644 --- a/src/libs/Navigation/AppNavigator/useSplitNavigatorScreenOptions.ts +++ b/src/libs/Navigation/AppNavigator/useSplitNavigatorScreenOptions.ts @@ -19,10 +19,8 @@ import useModalCardStyleInterpolator from './useModalCardStyleInterpolator'; const IS_MOBILE_SAFARI = isMobileSafari(); -// On mWeb Safari the centralScreen card is `position: fixed`, so `width: 100%` resolves against the viewport -// (including the landscape notch gutters), not the layout parent. Subtract the safe-area -// insets so the card is sized to the usable safe region instead of overflowing. -const NARROW_CARD_SAFE_AREA_WIDTH = 'calc(100% - env(safe-area-inset-left) - env(safe-area-inset-right))'; +// `dvw` instead of `%`: a percentage resolves against the transformed parent card, whose box already has the gutters removed, insetting them twice. +const NARROW_CARD_SAFE_AREA_WIDTH = 'calc(100dvw - env(safe-area-inset-left) - env(safe-area-inset-right))'; type SplitNavigatorScreenOptions = { sidebarScreen: PlatformStackNavigationOptions; @@ -54,7 +52,7 @@ const useSplitNavigatorScreenOptions = () => { cardStyleInterpolator: (props: StackCardInterpolationProps) => modalCardStyleInterpolator({props, enter: {kind: 'slide-from-width'}}), cardStyle: { ...StyleUtils.getNavigationModalCardStyle(), - width: shouldUseNarrowLayout ? '100%' : variables.sideBarWithLHBWidth, + width: shouldUseNarrowLayout ? NARROW_CARD_SAFE_AREA_WIDTH : variables.sideBarWithLHBWidth, marginLeft: shouldUseNarrowLayout ? 0 : -variables.sideBarWithLHBWidth, ...(shouldUseNarrowLayout ? {} : themeStyles.borderRight), },