Skip to content
TypeScript

fix(mobile): the Duo sidebar changes with the rotation, not after it (#24951)

Julius Marminge40ec16a9b655
diff --git a/apps/mobile/deps/react-native-screens-5.0.0-t3.43.tgz b/apps/mobile/deps/react-native-screens-5.0.0-t3.43.tgz
deleted file mode 100644
index 9406a8d7fcf..00000000000
Binary files a/apps/mobile/deps/react-native-screens-5.0.0-t3.43.tgz and /dev/null differ
diff --git a/apps/mobile/deps/react-native-screens-5.0.0-t3.44.tgz b/apps/mobile/deps/react-native-screens-5.0.0-t3.44.tgz
new file mode 100644
index 00000000000..9346f85dd02
Binary files /dev/null and b/apps/mobile/deps/react-native-screens-5.0.0-t3.44.tgz differ
diff --git a/apps/mobile/package.json b/apps/mobile/package.json
index 5ee32982a49..c99de977505 100644
--- a/apps/mobile/package.json
+++ b/apps/mobile/package.json
@@ -134,7 +134,7 @@
"react-native-pdf-jsi": "5.0.0",
"react-native-reanimated": "4.7.1",
"react-native-safe-area-context": "~5.10.1",
- "react-native-screens": "file:deps/react-native-screens-5.0.0-t3.43.tgz",
+ "react-native-screens": "file:deps/react-native-screens-5.0.0-t3.44.tgz",
"react-native-svg": "15.16.0",
"react-native-webview": "14.0.1",
"react-native-worklets": "0.13.0",
diff --git a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
index 872f1f521f7..afb6366b6ee 100644
--- a/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
+++ b/apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx
@@ -743,6 +743,24 @@ function AdaptiveWorkspaceLayoutContent(
});
};
+ // Rotating flips the overlay; until the new size reaches JS, predict the reset above.
+ const sidebarOverRotates =
+ nativeWorkspace && nativeMetrics?.hasHinge === true && layout.usesSplitView;
+ // The current orientation's panes already account for an inspector that needs the sidebar's room.
+ const sidebarInLandscape = baseLayout.primarySidebarOverlaysContent
+ ? primarySidebarPinned || primarySidebarPreferredVisible
+ : panes.primarySidebarVisible;
+ const sidebarInPortrait =
+ primarySidebarPinned ||
+ (baseLayout.primarySidebarOverlaysContent
+ ? overlaySidebar.visible
+ : isWorkspaceListPath(pathname));
+ const sidebarByOrientation = useMemo(
+ () =>
+ sidebarOverRotates ? { landscape: sidebarInLandscape, portrait: sidebarInPortrait } : null,
+ [sidebarInLandscape, sidebarInPortrait, sidebarOverRotates],
+ );
+
const contextValue = {
layout,
panes,
@@ -762,6 +780,7 @@ function AdaptiveWorkspaceLayoutContent(
setAuxiliaryPaneWidth,
composerKeyboardActive,
setComposerEditing,
+ sidebarByOrientation,
};
if (nativeWorkspace) {
diff --git a/apps/mobile/src/features/layout/adaptive-workspace-context.ts b/apps/mobile/src/features/layout/adaptive-workspace-context.ts
index 4f5f2033e02..7cfeb3e76fb 100644
--- a/apps/mobile/src/features/layout/adaptive-workspace-context.ts
+++ b/apps/mobile/src/features/layout/adaptive-workspace-context.ts
@@ -41,6 +41,11 @@ interface AdaptiveWorkspaceContextValue {
* sidebar and rail step aside and the thread header drops to one line.
*/
readonly composerKeyboardActive: boolean;
+ /**
+ * Whether the sidebar shows in each orientation, where it floats over the content in portrait
+ * (the unfolded Duo). The native split switches between them as a rotation starts.
+ */
+ readonly sidebarByOrientation: { readonly landscape: boolean; readonly portrait: boolean } | null;
/** The thread composer reports its focus so the layout can make room for typing. */
readonly setComposerEditing: (editing: boolean) => void;
}
@@ -73,6 +78,7 @@ export const AdaptiveWorkspaceContext = createContext<AdaptiveWorkspaceContextVa
openWorkspaceTab: () => undefined,
setAuxiliaryPaneWidth: () => undefined,
composerKeyboardActive: false,
+ sidebarByOrientation: null,
setComposerEditing: () => undefined,
});
diff --git a/apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx b/apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx
index 5a42b61d259..e94a5ea9296 100644
--- a/apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx
+++ b/apps/mobile/src/features/layout/createWorkspaceStackNavigator.ios.tsx
@@ -182,6 +182,7 @@ function WorkspaceColumns(
toggleAuxiliaryPane,
startNewTask,
openWorkspaceTab,
+ sidebarByOrientation,
} = useAdaptiveWorkspaceLayout();
const deviceType = useDeviceType();
const settingsDetailIn = (detail: readonly Route[]) =>
@@ -302,7 +303,13 @@ function WorkspaceColumns(
<Split.Host
ref={hostRef}
testID="adaptive-workspace-layout"
- preferredSplitBehavior={layout.primarySidebarOverlaysContent ? "overlay" : "tile"}
+ preferredSplitBehavior={
+ !sidebarByOrientation && layout.primarySidebarOverlaysContent ? "overlay" : "tile"
+ }
+ portraitPreferredSplitBehavior={sidebarByOrientation ? "overlay" : undefined}
+ portraitPreferredDisplayMode={
+ sidebarByOrientation ? sidebarDisplayMode(sidebarByOrientation.portrait, true) : undefined
+ }
primaryBackgroundStyle={deviceType === "pad" ? "none" : "default"}
topColumnForCollapsing={compactColumn}
onCollapse={() => {
@@ -326,14 +333,17 @@ function WorkspaceColumns(
openWorkspaceTab(tab ?? "threads", { columns: true });
}}
preferredDisplayMode={
- // UIKit applies the mode as a collapsed split expands, before the new width reaches JS, so a
- // collapsed split already carries the sidebar the expanded one will show.
- (layout.usesSplitView ? panes.primarySidebarVisible : panes.primarySidebarWhenExpanded) ||
- (!layout.usesSplitView && !activeDetailKey)
- ? layout.primarySidebarOverlaysContent
- ? "oneOverSecondary"
- : "oneBesideSecondary"
- : "secondaryOnly"
+ sidebarByOrientation
+ ? sidebarDisplayMode(sidebarByOrientation.landscape, false)
+ : sidebarDisplayMode(
+ // UIKit applies the mode as a collapsed split expands, before the new width reaches
+ // JS, so a collapsed split already carries the sidebar the expanded one will show.
+ (layout.usesSplitView
+ ? panes.primarySidebarVisible
+ : panes.primarySidebarWhenExpanded) ||
+ (!layout.usesSplitView && !activeDetailKey),
+ layout.primarySidebarOverlaysContent,
+ )
}
onDisplayModeWillChange={({ nativeEvent }) => {
if (!layout.primarySidebarOverlaysContent) return;
@@ -604,3 +614,8 @@ export function createWorkspaceStackNavigator<
>(config?: Config): TypedNavigator<TypeBag, Config> {
return createNavigatorFactory(WorkspaceStackNavigator)(config);
}
+
+function sidebarDisplayMode(visible: boolean, overlay: boolean) {
+ if (!visible) return "secondaryOnly";
+ return overlay ? "oneOverSecondary" : "oneBesideSecondary";
+}
diff --git a/docs/operations/mobile-screens-fork.md b/docs/operations/mobile-screens-fork.md
index 23ad1387b78..a48c0f924bf 100644
--- a/docs/operations/mobile-screens-fork.md
+++ b/docs/operations/mobile-screens-fork.md
@@ -1,7 +1,7 @@
# Building the mobile Screens dependency
The mobile v5 stack uses a committed tarball from the
-[T3 Screens fork](https://github.com/PixPMusic/react-native-screens/tree/t3-v5.0.0-t3.43).
+[T3 Screens fork](https://github.com/pingdotgg/react-native-screens/tree/t3-v5.0.0-t3.44).
The fork owns the integration changes; the app does not patch this package.
Each archive includes compiled JavaScript, declarations, native source and
`t3-fork.json` recording its version, source commit and upstream base.
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 5a0ef250c52..072482613ce 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -559,7 +559,7 @@ importers:
'@react-navigation/native-stack':
specifier: 7.21.0
- version: 7.21.0(patch_hash=990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42)(52d9b4ccdf06285c715244e02709d347)
+ version: 7.21.0(patch_hash=990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42)(90b832078186123c182216792ec43c25)
'@t3tools/client-runtime':
specifier: workspace:*
version: link:../../packages/client-runtime
@@ -762,8 +762,8 @@ importers:
specifier: ~5.10.1
react-native-screens:
- specifier: file:deps/react-native-screens-5.0.0-t3.43.tgz
+ specifier: file:deps/react-native-screens-5.0.0-t3.44.tgz
react-native-svg:
specifier: 15.16.0
@@ -10719,9 +10719,9 @@ packages:
react: '*'
react-native: '*'
- react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.43.tgz:
- resolution: {integrity: sha512-kknkDmA26Vygu00QP5bThYHiSdbjJNxLncFSLEKC22lCZ7LAzuQJkC44ra53b1VEcP9TPKsQHKK8ateJNvNE2Q==, tarball: file:apps/mobile/deps/react-native-screens-5.0.0-t3.43.tgz}
- version: 5.0.0-t3.43
+ react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.44.tgz:
+ resolution: {integrity: sha512-hs8Q9FodRg8JWPk7QeohJwaNrndgxHajgXdTfVH1RpwFhmyWSJV0/mMzqYKh3qX/jTD7TBnRWKyKuvMFwHGF6w==, tarball: file:apps/mobile/deps/react-native-screens-5.0.0-t3.44.tgz}
+ version: 5.0.0-t3.44
peerDependencies:
react: '*'
react-native: '*'
@@ -15658,7 +15658,7 @@ snapshots:
optionalDependencies:
- '@react-navigation/[email protected](patch_hash=990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42)(52d9b4ccdf06285c715244e02709d347)':
+ '@react-navigation/[email protected](patch_hash=990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42)(90b832078186123c182216792ec43c25)':
dependencies:
'@react-navigation/elements': 2.9.45(d8845bac868f4d8a58c8a8f12ad0d4a5)
@@ -15666,7 +15666,7 @@ snapshots:
react: 19.3.0
sf-symbols-typescript: 2.2.0
warn-once: 0.1.1
transitivePeerDependencies:
@@ -21318,7 +21318,7 @@ snapshots:
react: 19.3.0
dependencies:
react: 19.3.0
react-freeze: 1.0.4([email protected])