Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
ab5dd54
Use narrow layout in landscape mode mWeb
GCyganek Aug 5, 2026
1a187dc
keyboardShouldPersistTaps
GCyganek Aug 6, 2026
23ce776
Fix isInLandscapeMode mWeb check
GCyganek Aug 6, 2026
a477b6c
isInLandscapeMode web improvements
GCyganek Aug 7, 2026
0bfcc9f
isMobile import
GCyganek Aug 7, 2026
b136cda
Merge branch 'main' into @GCyganek/landscape-mweb/use-narrow-layout-f…
GCyganek Aug 12, 2026
9f87c27
Listen to orientation changes
GCyganek Aug 12, 2026
bbc63a9
Merge branch 'main' into @GCyganek/landscape-mweb/use-narrow-layout-f…
GCyganek Aug 21, 2026
3bb74c2
Fix landscape mode true on tablets
GCyganek Aug 21, 2026
17f2adc
Recompute after attach
GCyganek Aug 21, 2026
6145aca
Prioritize usage of isInLandscapeMode from useResponsiveLayout if alr…
GCyganek Aug 24, 2026
50e34ac
Fix layout flickers on orientation changes
GCyganek Aug 24, 2026
bc78c26
Merge branch 'main' into @GCyganek/landscape-mweb/use-narrow-layout-f…
GCyganek Aug 24, 2026
0ab7037
Fix knip check
GCyganek Aug 24, 2026
908f7f7
useEmojiPickerMenu use isLandscapeMenu util
GCyganek Aug 24, 2026
f1f2fa9
Fix crashes on iOS safari mWeb when rotating to landscape with open k…
GCyganek Aug 25, 2026
a48c977
Fix isMediumScreenWidth check in landscapem ode
GCyganek Aug 25, 2026
ae9ccba
delete console.log
GCyganek Aug 25, 2026
e590bc2
Use the same default as getIsNarrowLayout()
GCyganek Aug 26, 2026
17c07e9
Fix Save view screen safe area iOS Safari
GCyganek Aug 26, 2026
58ba55b
Merge branch 'main' into @GCyganek/landscape-mweb/use-narrow-layout-f…
GCyganek Aug 28, 2026
31569d3
useScrollableWrapper
GCyganek Aug 28, 2026
acf498d
Merge branch 'main' into @GCyganek/landscape-mweb/use-narrow-layout-f…
GCyganek Sep 1, 2026
4a610aa
Fix GPS; shouldUseNarrowLayout do not check isInLandscapeMode
GCyganek Sep 1, 2026
81dba94
getStyleWithEnvSafeAreaPadding()
GCyganek Sep 1, 2026
4a96104
SearchSavePage options
GCyganek Sep 1, 2026
cf57701
Fix Workspace screens having double safe area paddings
GCyganek Sep 1, 2026
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
7 changes: 1 addition & 6 deletions src/components/CenteredModalLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -44,12 +41,10 @@ type CenteredModalLayoutProps = {

function CenteredModalLayout({children, width, height, onBackdropPress, contentStyle, addBottomSafeAreaPadding = true}: CenteredModalLayoutProps) {
const styles = useThemeStyles();
const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout();
const {windowWidth, windowHeight} = useWindowDimensions();
const {onboardingIsMediumOrLargerScreenWidth, isInLandscapeMode} = useResponsiveLayout();

const shouldDockToBottom = !onboardingIsMediumOrLargerScreenWidth;

const isInLandscapeMode = isInLandscapeModeUtil(windowWidth, windowHeight);
const safeAreaHorizontalPadding = useSafeAreaHorizontalPadding();
const safeAreaStyle = useBottomSafeSafeAreaPaddingStyle({
addBottomSafeAreaPadding: addBottomSafeAreaPadding && !isInLandscapeMode && shouldDockToBottom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<RNScrollView>(null);
Expand Down
6 changes: 2 additions & 4 deletions src/components/FeatureTraining/primitives/Illustration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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';
Expand Down Expand Up @@ -88,11 +87,10 @@ function Illustration({
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 [measuredAspectRatio, setMeasuredAspectRatio] = useState(aspectRatioProp ?? VIDEO_ASPECT_RATIO);
const isInLandscapeMode = isInLandscapeModeUtil(windowWidth, windowHeight);

const animationRef = useRef<LottieView | null>(null);
useEffect(() => {
Expand Down
7 changes: 2 additions & 5 deletions src/components/FeatureTrainingModal.tsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -53,9 +51,8 @@ function FeatureTrainingModal({
children,
}: 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);

Expand Down
4 changes: 2 additions & 2 deletions src/components/SidePanel/SidePanelModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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}
Expand Down
16 changes: 0 additions & 16 deletions src/hooks/useIsInLandscapeMode/index.native.ts

This file was deleted.

12 changes: 10 additions & 2 deletions src/hooks/useIsInLandscapeMode/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
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 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 false;
const {windowWidth, windowHeight} = useWindowDimensions();

return isInLandscapeMode(windowWidth, windowHeight);
}

export default useIsInLandscapeMode;
12 changes: 8 additions & 4 deletions src/hooks/useResponsiveLayout/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 isMediumScreenWidth = windowWidth > variables.mobileResponsiveWidthBreakpoint && windowWidth <= variables.tabletResponsiveWidthBreakpoint;
const onboardingIsMediumOrLargerScreenWidth = windowWidth > variables.mobileResponsiveWidthBreakpoint;
const isSmallScreenWidth = windowWidth <= variables.mobileResponsiveWidthBreakpoint || isInLandscapeMode;
const isMediumScreenWidth = windowWidth > variables.mobileResponsiveWidthBreakpoint && windowWidth <= variables.tabletResponsiveWidthBreakpoint && !isInLandscapeMode;
const onboardingIsMediumOrLargerScreenWidth = !isInLandscapeMode && windowWidth > variables.mobileResponsiveWidthBreakpoint;
const isLargeScreenWidth = windowWidth > variables.tabletResponsiveWidthBreakpoint;
const isExtraLargeScreenWidth = windowWidth > variables.sidePanelResponsiveWidthBreakpoint;
const isExtraSmallScreenWidth = windowWidth <= variables.extraSmallMobileResponsiveWidthBreakpoint;
Expand Down Expand Up @@ -79,6 +83,6 @@ export default function useResponsiveLayout(): ResponsiveLayoutResult {
isLargeScreenWidth,
isExtraLargeScreenWidth,
isSmallScreen,
isInLandscapeMode: false,
isInLandscapeMode,
};
}
6 changes: 5 additions & 1 deletion src/hooks/useSafeAreaPaddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
28 changes: 21 additions & 7 deletions src/hooks/useViewportOffsetTop/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand Down Expand Up @@ -68,13 +71,13 @@ function useWideModalStackScreenOptions() {
contentStyle: styles.navigationScreenCardStyle,
},
web: {
cardStyle: 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],
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ function RightModalNavigator({navigation, route}: RightModalNavigatorProps) {
<Stack.Screen
name={SCREENS.RIGHT_MODAL.SEARCH_SAVE}
getComponent={loadSearchSavePage}
options={modalStackScreenOptions}
/>
<Stack.Screen
name={SCREENS.RIGHT_MODAL.SEARCH_ADVANCED_FILTERS}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}),
},
Expand Down Expand Up @@ -113,7 +115,7 @@ 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.getStyleWithEnvSafeAreaPadding(StyleUtils.getNavigationModalCardStyle()) : {...themeStyles.h100, width: '100%'},
},
},
} satisfies RootNavigatorScreenOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import useModalCardStyleInterpolator from './useModalCardStyleInterpolator';

const IS_MOBILE_SAFARI = isMobileSafari();

// `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;
centralScreen: PlatformStackNavigationOptions;
Expand Down Expand Up @@ -49,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),
},
Expand All @@ -66,7 +69,7 @@ const useSplitNavigatorScreenOptions = () => {
web: {
cardStyleInterpolator: (props: StackCardInterpolationProps) => modalCardStyleInterpolator({props, enter: centralScreenEnter}),
cardStyle: shouldUseNarrowLayout
? StyleUtils.getNavigationModalCardStyle()
? {...StyleUtils.getNavigationModalCardStyle(), width: NARROW_CARD_SAFE_AREA_WIDTH}
Comment thread
GCyganek marked this conversation as resolved.
Resolved
: {
...themeStyles.h100,
},
Expand Down
3 changes: 2 additions & 1 deletion src/libs/getIsNarrowLayout/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import getIsSmallScreenWidth from '@libs/getIsSmallScreenWidth';
import isInLandscapeMode from '@libs/isInLandscapeMode';

export default function getIsNarrowLayout() {
return getIsSmallScreenWidth();
return getIsSmallScreenWidth() || isInLandscapeMode();
}
3 changes: 2 additions & 1 deletion src/libs/isInLandscapeMode/index.native.ts
Original file line number Diff line number Diff line change
@@ -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;
}
36 changes: 33 additions & 3 deletions src/libs/isInLandscapeMode/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
import {isMobile} from '@libs/Browser';

import {Dimensions} from 'react-native';

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();

const screenShortSide = Math.min(window.screen.width, window.screen.height);
const screenLongSide = Math.max(window.screen.width, window.screen.height);

function getViewportWidth(): number {
return Dimensions.get('window').width;
}

/**
* We only want to change UI according to the landscape mode on native platforms.
* 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).
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export default function isInLandscapeMode(windowWidth: number, windowHeight: number): boolean {
return false;
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;
Loading
Loading