Skip to content

Commit 7699114

Browse files
fix(android): the thread pane reflows once, as the sidebar starts to move
Opening the split-view sidebar kept the thread laid out at its old width, clipped, until the slide ended, then reflowed it. That late reflow is what showed as the feed catching up after the sidebar had landed, most often when closing the keyboard brings the sidebar back. The pane now takes its new width in the commit that toggles a pane, and holds still against the edge that does not move: a sidebar sliding in fills the strip beside it, and one sliding out uncovers the rest of the pane. Nothing reflows after the panes land. A hinge resize follows the same rule, and an inspector keeps the left edge still. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 471ee65 commit 7699114

1 file changed

Lines changed: 60 additions & 47 deletions

File tree

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

Lines changed: 60 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -530,82 +530,91 @@ function AdaptiveWorkspaceLayoutContent(
530530
const contentTargetWidth = layout.usesSplitView
531531
? Math.max(0, panes.contentPaneWidth - inspectorColumnTargetWidth)
532532
: null;
533-
const [contentSizing, setContentSizing] = useState({
533+
const [listPaneSizing, setListPaneSizing] = useState({
534534
viewportWidth,
535535
workspacePage,
536-
target: contentTargetWidth,
537536
sidebarVisible: panes.primarySidebarVisible,
538-
width: contentTargetWidth,
539537
listPaneTarget: layout.listPaneWidth,
540538
listPaneFloor: layout.listPaneWidth,
541539
listPaneCeiling: layout.listPaneWidth,
542540
revision: 0,
543541
});
544542
if (
545543
Platform.OS === "android" &&
546-
(contentSizing.viewportWidth !== viewportWidth ||
547-
contentSizing.workspacePage !== workspacePage ||
548-
contentSizing.target !== contentTargetWidth ||
549-
contentSizing.sidebarVisible !== panes.primarySidebarVisible ||
550-
contentSizing.listPaneTarget !== layout.listPaneWidth)
544+
(listPaneSizing.viewportWidth !== viewportWidth ||
545+
listPaneSizing.workspacePage !== workspacePage ||
546+
listPaneSizing.sidebarVisible !== panes.primarySidebarVisible ||
547+
listPaneSizing.listPaneTarget !== layout.listPaneWidth)
551548
) {
552-
// A workspace page swaps the sidebar in the same frame, so nothing animates to wait for.
553-
const sameViewport =
554-
contentSizing.viewportWidth === viewportWidth &&
555-
contentSizing.workspacePage === workspacePage;
556-
const openingSidebar =
557-
sameViewport && !contentSizing.sidebarVisible && panes.primarySidebarVisible;
558549
// A book-posture hinge resizes the visible list pane instead of revealing it.
559550
const resizingSidebar =
560-
sameViewport &&
561-
contentSizing.sidebarVisible &&
551+
listPaneSizing.viewportWidth === viewportWidth &&
552+
listPaneSizing.workspacePage === workspacePage &&
553+
listPaneSizing.sidebarVisible &&
562554
panes.primarySidebarVisible &&
563-
contentSizing.listPaneTarget !== layout.listPaneWidth;
564-
const keepWide =
565-
(openingSidebar || resizingSidebar) &&
566-
contentSizing.width !== null &&
567-
contentTargetWidth !== null;
568-
setContentSizing({
555+
listPaneSizing.listPaneTarget !== layout.listPaneWidth;
556+
setListPaneSizing({
569557
viewportWidth,
570558
workspacePage,
571-
target: contentTargetWidth,
572559
sidebarVisible: panes.primarySidebarVisible,
573-
// Clip the wide navigator while the sidebar opens or widens, then reflow once at the
574-
// end. Narrowing it first exposes an empty strip before the sidebar arrives.
575-
width: keepWide
576-
? Math.max(contentSizing.width ?? 0, contentTargetWidth ?? 0)
577-
: contentTargetWidth,
578560
listPaneTarget: layout.listPaneWidth,
579561
// While a hinge resizes the list, its width follows the pane edge within this span. A
580562
// retarget mid-animation widens the span, since the edge is still somewhere inside it.
581563
listPaneFloor: resizingSidebar
582-
? Math.min(contentSizing.listPaneFloor ?? 0, layout.listPaneWidth ?? 0)
564+
? Math.min(listPaneSizing.listPaneFloor ?? 0, layout.listPaneWidth ?? 0)
583565
: layout.listPaneWidth,
584566
listPaneCeiling: resizingSidebar
585-
? Math.max(contentSizing.listPaneCeiling ?? 0, layout.listPaneWidth ?? 0)
567+
? Math.max(listPaneSizing.listPaneCeiling ?? 0, layout.listPaneWidth ?? 0)
586568
: layout.listPaneWidth,
587-
revision: contentSizing.revision + 1,
569+
revision: listPaneSizing.revision + 1,
588570
});
589571
}
590-
const settleContentWidth = (revision: number) => {
591-
setContentSizing((current) =>
572+
const settleListPane = (revision: number) => {
573+
setListPaneSizing((current) =>
592574
current.revision !== revision ||
593-
(current.width === current.target &&
594-
current.listPaneFloor === current.listPaneTarget &&
575+
(current.listPaneFloor === current.listPaneTarget &&
595576
current.listPaneCeiling === current.listPaneTarget)
596577
? current
597578
: {
598579
...current,
599-
width: current.target,
600580
listPaneFloor: current.listPaneTarget,
601581
listPaneCeiling: current.listPaneTarget,
602582
},
603583
);
604584
};
605-
const listPaneFloor = contentSizing.listPaneFloor ?? 0;
606-
const listPaneCeiling = contentSizing.listPaneCeiling ?? 0;
607-
const contentSettledWidth = Platform.OS === "android" ? contentSizing.width : contentTargetWidth;
608-
const contentRevision = contentSizing.revision;
585+
const listPaneFloor = listPaneSizing.listPaneFloor ?? 0;
586+
const listPaneCeiling = listPaneSizing.listPaneCeiling ?? 0;
587+
const listPaneRevision = listPaneSizing.revision;
588+
// Android lays the content out at its new width as soon as a pane toggles, then holds it
589+
// against the edge that stays put while the other one slides, so nothing reflows after the
590+
// panes land. A sliding sidebar uncovers the strip it is about to fill, or covers the content
591+
// until it is gone.
592+
const contentLeftTarget =
593+
navigationRailWidth +
594+
(shouldRenderPrimarySidebar && !workspacePage && panes.primarySidebarVisible
595+
? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0)
596+
: 0);
597+
const [contentAnchor, setContentAnchor] = useState({
598+
viewportWidth,
599+
left: contentLeftTarget,
600+
inspector: inspectorColumnTargetWidth,
601+
end: false,
602+
});
603+
if (
604+
Platform.OS === "android" &&
605+
(contentAnchor.viewportWidth !== viewportWidth ||
606+
contentAnchor.left !== contentLeftTarget ||
607+
contentAnchor.inspector !== inspectorColumnTargetWidth)
608+
) {
609+
setContentAnchor({
610+
viewportWidth,
611+
left: contentLeftTarget,
612+
inspector: inspectorColumnTargetWidth,
613+
end:
614+
contentAnchor.viewportWidth === viewportWidth &&
615+
contentAnchor.inspector === inspectorColumnTargetWidth,
616+
});
617+
}
609618

610619
const renderedSidebarWidth = useSharedValue(
611620
panes.primarySidebarVisible ? (layout.listPaneWidth ?? 0) + (layout.listPaneGap ?? 0) : 0,
@@ -629,7 +638,7 @@ function AdaptiveWorkspaceLayoutContent(
629638
// The content beside it already took its final width when the page closed.
630639
renderedSidebarWidth.set(
631640
withTiming(targetWidth, snap ? { duration: 0 } : WORKSPACE_PANE_TIMING, (finished) => {
632-
if (finished && Platform.OS === "android") runOnJS(settleContentWidth)(contentRevision);
641+
if (finished && Platform.OS === "android") runOnJS(settleListPane)(listPaneRevision);
633642
}),
634643
);
635644
}, [
@@ -640,8 +649,8 @@ function AdaptiveWorkspaceLayoutContent(
640649
panes.primarySidebarVisible,
641650
renderedSidebarWidth,
642651
renderedRailWidth,
643-
settleContentWidth,
644-
contentRevision,
652+
settleListPane,
653+
listPaneRevision,
645654
workspacePage,
646655
]);
647656
const railAnimatedStyle = useAnimatedStyle(() => ({ width: renderedRailWidth.value }));
@@ -829,20 +838,24 @@ function AdaptiveWorkspaceLayoutContent(
829838
<View
830839
collapsable={false}
831840
style={
832-
contentSettledWidth !== null
841+
contentTargetWidth !== null
833842
? {
834843
flex: 1,
835-
width: contentSettledWidth,
844+
width: contentTargetWidth,
845+
alignSelf: contentAnchor.end ? "flex-end" : "flex-start",
836846
}
837847
: { flex: 1 }
838848
}
839849
>
850+
{/* Android holds the content still, so its floating controls keep its width. */}
840851
<WorkspaceContentWidthContext
841-
value={layout.usesSplitView ? renderedContentWidth : null}
852+
value={
853+
layout.usesSplitView && Platform.OS !== "android" ? renderedContentWidth : null
854+
}
842855
>
843856
<WorkspaceSettledContentWidthContext
844857
value={
845-
Platform.OS === "android" && layout.usesSplitView ? contentSettledWidth : null
858+
Platform.OS === "android" && layout.usesSplitView ? contentTargetWidth : null
846859
}
847860
>
848861
{props.children}

0 commit comments

Comments
 (0)