Skip to content

Commit 9151430

Browse files
committed
fix(mobile): medium Android windows keep the rail's room and the sidebar's place
On a 600-720dp Android window, such as an unfolded OPPO Find N6 (692dp), the sidebar floats over a page. Two things went wrong in that mode: - The floating sidebar's animated `left` offset stayed on the view after the list came back. The style was dropped from the array, and Reanimated keeps the last value of keys a dropped animated style set, so the docked sidebar sat a rail's width to the right of the rail and its rows were clipped. The style now always applies and sets left to 0 when the sidebar is docked. - In float mode the rail took no room, so the page started at the screen edge under the always-drawn rail and lost its first 72dp. The rail now keeps its room in both modes; only the list pane floats over the page.
1 parent ade4730 commit 9151430

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

‎apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@ function AdaptiveWorkspaceLayoutContent(
364364
floatingTabs.row,
365365
floatingTabsEnabled,
366366
]);
367-
// A floating sidebar brings the rail with it.
368-
const width = viewportWidth - (sidebarFloats ? 0 : navigationRailWidth);
367+
// The rail keeps its room even while the sidebar floats; only the list pane overlays the page.
368+
const width = viewportWidth - navigationRailWidth;
369369
// The sidebar stays mounted under a workspace page, so its list is ready on the way back.
370370
const shouldRenderPrimarySidebar = layout.usesSplitView;
371371
const fileInspector = useMemo(
@@ -779,7 +779,7 @@ function AdaptiveWorkspaceLayoutContent(
779779
// panes land. A sliding sidebar uncovers the strip it is about to fill, or covers the content
780780
// until it is gone.
781781
const contentLeftTarget = sidebarFloats
782-
? 0
782+
? navigationRailWidth
783783
: navigationRailWidth +
784784
(shouldRenderPrimarySidebar && !workspacePage && panes.primarySidebarVisible
785785
? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0)
@@ -859,7 +859,9 @@ function AdaptiveWorkspaceLayoutContent(
859859
workspacePage,
860860
]);
861861
const railAnimatedStyle = useAnimatedStyle(() => ({ width: renderedRailWidth.value }));
862-
const floatingSidebarAnimatedStyle = useAnimatedStyle(() => ({ left: renderedRailWidth.value }));
862+
const floatingSidebarAnimatedStyle = useAnimatedStyle(() => ({
863+
left: sidebarFloats ? renderedRailWidth.value : 0,
864+
}));
863865
const floatingSidebarOpen = sidebarFloats && panes.primarySidebarVisible;
864866
// Its own value, so a sidebar that was beside a list doesn't dim the page as it leaves.
865867
const scrimOpacity = useSharedValue(0);
@@ -931,7 +933,7 @@ function AdaptiveWorkspaceLayoutContent(
931933
Math.max(
932934
0,
933935
viewportWidth -
934-
(sidebarFloats ? 0 : renderedRailWidth.value) -
936+
renderedRailWidth.value -
935937
(workspacePage || sidebarFloats ? 0 : drawnSidebarWidth.value) -
936938
renderedInspectorWidth.value,
937939
),
@@ -1049,10 +1051,7 @@ function AdaptiveWorkspaceLayoutContent(
10491051
>
10501052
<AndroidHingeObserver onChange={handleHingeChange} />
10511053
{shouldRenderNavigationRail ? (
1052-
<Animated.View
1053-
className={sidebarFloats ? "absolute inset-y-0 left-0" : "shrink self-stretch"}
1054-
style={railAnimatedStyle}
1055-
/>
1054+
<Animated.View className="shrink self-stretch" style={railAnimatedStyle} />
10561055
) : null}
10571056
{shouldRenderPrimarySidebar && layout.listPaneWidth !== null ? (
10581057
<Animated.View
@@ -1069,11 +1068,9 @@ function AdaptiveWorkspaceLayoutContent(
10691068
style={[
10701069
workspacePage ? { position: "absolute", top: 0, bottom: 0, left: 0 } : null,
10711070
sidebarFloats
1072-
? [
1073-
{ position: "absolute", top: 0, bottom: 0, zIndex: 2, elevation: 8 },
1074-
floatingSidebarAnimatedStyle,
1075-
]
1071+
? { position: "absolute", top: 0, bottom: 0, zIndex: 2, elevation: 8 }
10761072
: null,
1073+
floatingSidebarAnimatedStyle,
10771074
sidebarAnimatedStyle,
10781075
]}
10791076
>

0 commit comments

Comments
 (0)