Skip to content

Commit 2da1b74

Browse files
fix(mobile): the unfolded Duo sidebar no longer pops back in while resizing Files (#33510)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 1676313 commit 2da1b74

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,10 @@ function AdaptiveWorkspaceLayoutContent(
245245
const [primarySidebarPreferredVisible, setPrimarySidebarPreferredVisible] = useState(true);
246246
const [fileInspectorPreferredVisible, setFileInspectorPreferredVisible] = useState(true);
247247
const [nativeInspectorWidthFraction, setNativeInspectorWidthFraction] = useState(0.4);
248+
const horizontalSafeArea =
249+
(nativeMetrics?.safeArea.left ?? 0) + (nativeMetrics?.safeArea.right ?? 0);
248250
const inspectorWidthFor = (fraction: number) =>
249-
nativeInspectorColumnWidth({
250-
viewportWidth,
251-
horizontalSafeArea:
252-
(nativeMetrics?.safeArea.left ?? 0) + (nativeMetrics?.safeArea.right ?? 0),
253-
fraction,
254-
});
251+
nativeInspectorColumnWidth({ viewportWidth, horizontalSafeArea, fraction });
255252
const nativeInspectorWidth = inspectorWidthFor(nativeInspectorWidthFraction);
256253
const [fileInspectorPreferredWidth, setFileInspectorPreferredWidth] = useState<number | null>(
257254
null,
@@ -408,6 +405,7 @@ function AdaptiveWorkspaceLayoutContent(
408405
deriveWorkspacePaneLayout({
409406
layout,
410407
viewportWidth: width,
408+
horizontalSafeArea,
411409
nativeWorkspace,
412410
primarySidebarFloats: sidebarFloats,
413411
primarySidebarPreferredVisible: showPrimarySidebar,
@@ -419,6 +417,7 @@ function AdaptiveWorkspaceLayoutContent(
419417
}),
420418
[
421419
nativeInspectorWidth,
420+
horizontalSafeArea,
422421
fileInspectorPreferredVisible,
423422
fileInspectorPreferredWidth,
424423
inspectorActive,
@@ -438,6 +437,7 @@ function AdaptiveWorkspaceLayoutContent(
438437
: deriveWorkspacePaneLayout({
439438
layout,
440439
viewportWidth: width,
440+
horizontalSafeArea,
441441
nativeWorkspace,
442442
primarySidebarFloats: sidebarFloats,
443443
primarySidebarPreferredVisible: sidebarWithoutKeyboard,
@@ -448,6 +448,7 @@ function AdaptiveWorkspaceLayoutContent(
448448
}).primarySidebarVisible,
449449
[
450450
nativeInspectorWidth,
451+
horizontalSafeArea,
451452
fileInspectorPreferredVisible,
452453
fileInspectorPreferredWidth,
453454
inspectorActive,

‎apps/mobile/src/lib/layout.test.ts‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,24 +155,27 @@ describe("isPrimarySidebarPinned", () => {
155155

156156
describe("deriveWorkspacePaneLayout", () => {
157157
it.each([
158-
{ width: 1_194, height: 834, suppressed: false },
159-
{ width: 1_032, height: 1_376, suppressed: true },
158+
{ width: 1_194, height: 834, horizontalSafeArea: 0, fraction: 0.4, suppressed: false },
159+
{ width: 1_032, height: 1_376, horizontalSafeArea: 0, fraction: 0.4, suppressed: true },
160+
// The unfolded Duo's system bar leaves no room for the sidebar beside even the narrowest inspector.
161+
{ width: 951, height: 669, horizontalSafeArea: 76, fraction: 0, suppressed: true },
160162
])(
161163
"steps the sidebar aside for the native inspector only when the page gets too narrow ($width wide)",
162-
({ width, height, suppressed }) => {
164+
({ width, height, horizontalSafeArea, fraction, suppressed }) => {
163165
const layout = deriveLayout({ width, height });
164166
for (const primarySidebarPreferredVisible of [true, false]) {
165167
expect(
166168
deriveWorkspacePaneLayout({
167169
layout,
168170
viewportWidth: width,
171+
horizontalSafeArea,
169172
nativeWorkspace: true,
170173
primarySidebarPreferredVisible,
171174
auxiliaryPanePreferredVisible: true,
172175
nativeInspectorWidth: nativeInspectorColumnWidth({
173176
viewportWidth: width,
174-
horizontalSafeArea: 0,
175-
fraction: 0.4,
177+
horizontalSafeArea,
178+
fraction,
176179
}),
177180
}),
178181
).toMatchObject({

‎apps/mobile/src/lib/layout.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ export function isPrimarySidebarPinned(input: {
218218
export function deriveWorkspacePaneLayout(input: {
219219
readonly layout: Layout;
220220
readonly viewportWidth: number;
221+
/** Width UIKit keeps out of its columns, such as the Duo's system bar. */
222+
readonly horizontalSafeArea?: number;
221223
readonly nativeWorkspace?: boolean;
222224
/** Whether the sidebar floats over the content rather than taking its room; medium by default. */
223225
readonly primarySidebarFloats?: boolean;
@@ -251,7 +253,11 @@ export function deriveWorkspacePaneLayout(input: {
251253
auxiliaryPaneVisible &&
252254
inspectorWidth !== null &&
253255
input.layout.listPaneWidth !== null &&
254-
viewportWidth - input.layout.listPaneWidth - (input.layout.listPaneGap ?? 0) - inspectorWidth <
256+
viewportWidth -
257+
(input.nativeWorkspace ? (input.horizontalSafeArea ?? 0) : 0) -
258+
input.layout.listPaneWidth -
259+
(input.layout.listPaneGap ?? 0) -
260+
inspectorWidth <
255261
(input.nativeWorkspace ? NATIVE_INSPECTOR_MIN_MAIN_WIDTH : FILE_INSPECTOR_MIN_MAIN_WIDTH);
256262
const primarySidebarVisible =
257263
preferredPrimarySidebarVisible && !primarySidebarSuppressedByAuxiliary;

0 commit comments

Comments
 (0)