Skip to content

Commit 47636ab

Browse files
committed
fix(mobile): reserve Duo list space above search
1 parent f91b0bb commit 47636ab

3 files changed

Lines changed: 71 additions & 13 deletions

File tree

‎apps/mobile/src/features/workspace/WorkspaceRootScreen.tsx‎

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ import { CompactBrandTitle } from "../../components/CompactBrandTitle";
1212
import { AndroidScreenHeader } from "../../components/ui/AndroidScreenHeader";
1313
import { NativeStackScreenOptions } from "../../native/StackHeader";
1414
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
15+
import { isDuoDevice } from "../../lib/device-type";
1516
import {
1617
useDeviceType,
18+
useDuoBottomBarInset,
1719
useNativeColumnLayoutMetrics,
1820
useNativeLayoutMetrics,
1921
} from "../../native/native-layout-metrics";
@@ -28,7 +30,11 @@ import {
2830
useWorkspaceTabs,
2931
} from "./WorkspaceTabsContext";
3032
import { WorkspaceToolbar } from "./WorkspaceToolbar";
31-
import { WORKSPACE_DOCK, workspaceToolbarHeight } from "./workspace-tabs-state";
33+
import {
34+
WORKSPACE_DOCK,
35+
workspaceSearchBottomClearance,
36+
workspaceToolbarHeight,
37+
} from "./workspace-tabs-state";
3238
import { WorkspaceSidebarTabs } from "./WorkspaceSidebarTabs";
3339
import {
3440
useCompactWorkspaceTabs,
@@ -79,6 +85,7 @@ function WorkspaceRootContent() {
7985
(nativeMetrics !== null && nativeMetrics.verticalBarEdge !== "none"));
8086
const width = columnMetrics?.width ?? windowWidth;
8187
const insets = useSafeAreaInsets();
88+
const bottomBarInset = useDuoBottomBarInset();
8289
const keyboardHeight = useKeyboardState((keyboard) => keyboard.height);
8390
const workspace = useWorkspaceTabs()!;
8491
const { state } = workspace;
@@ -97,18 +104,25 @@ function WorkspaceRootContent() {
97104
[width, navigation],
98105
);
99106
const tab = state.tabs[state.selectedTab];
100-
const bottomClearance = compactTabs
101-
? 64 + insets.bottom + 16
102-
: Platform.OS === "ios"
103-
? Math.max(insets.bottom, keyboardHeight) +
104-
(systemTabBar || sidebarTabs || tab.searchMode !== "resting"
105-
? sidebarPicker
106-
? 80
107-
: 16
108-
: WORKSPACE_DOCK.height + WORKSPACE_DOCK.bottomGap + 16)
109-
: keyboardHeight > 0 && tab.searchMode !== "resting"
110-
? keyboardHeight + 64
111-
: Math.max(insets.bottom, 12) + workspaceToolbarHeight(tab.searchMode) + 16;
107+
const bottomClearance =
108+
Platform.OS === "ios" && isDuoDevice(deviceType)
109+
? workspaceSearchBottomClearance({
110+
bottomInset: insets.bottom,
111+
bottomBarInset,
112+
keyboardHeight,
113+
})
114+
: compactTabs
115+
? 64 + insets.bottom + 16
116+
: Platform.OS === "ios"
117+
? Math.max(insets.bottom, keyboardHeight) +
118+
(systemTabBar || sidebarTabs || tab.searchMode !== "resting"
119+
? sidebarPicker
120+
? 80
121+
: 16
122+
: WORKSPACE_DOCK.height + WORKSPACE_DOCK.bottomGap + 16)
123+
: keyboardHeight > 0 && tab.searchMode !== "resting"
124+
? keyboardHeight + 64
125+
: Math.max(insets.bottom, 12) + workspaceToolbarHeight(tab.searchMode) + 16;
112126
const context = useMemo(() => ({ ...workspace, bottomClearance }), [workspace, bottomClearance]);
113127

114128
return (

‎apps/mobile/src/features/workspace/workspace-tabs-state.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,38 @@ import {
44
workspaceTabsReducer,
55
workspaceTabForNativeSlot,
66
resolveWorkspaceTabOrder,
7+
workspaceSearchBottomClearance,
78
} from "./workspace-tabs-state";
89

10+
describe("Duo list clearance", () => {
11+
it.each([18, 60])(
12+
"scrolls the last row above search with a %s-point native bar inset",
13+
(bottomBarInset) => {
14+
const clearance = workspaceSearchBottomClearance({
15+
bottomInset: 34,
16+
bottomBarInset,
17+
keyboardHeight: 0,
18+
});
19+
expect(clearance).toBe(bottomBarInset + 48 + 16);
20+
},
21+
);
22+
23+
it("keeps the last row above search when the keyboard lifts the field", () => {
24+
expect(
25+
workspaceSearchBottomClearance({ bottomInset: 34, bottomBarInset: 18, keyboardHeight: 300 }),
26+
).toBe(300 + 8 + 48 + 16);
27+
});
28+
29+
it("falls back to the field's safe-area spacing before native bar metrics arrive", () => {
30+
expect(workspaceSearchBottomClearance({ bottomInset: 34, keyboardHeight: 0 })).toBe(
31+
34 + 48 + 16,
32+
);
33+
expect(workspaceSearchBottomClearance({ bottomInset: 0, keyboardHeight: 0 })).toBe(
34+
12 + 48 + 16,
35+
);
36+
});
37+
});
38+
939
describe("workspace root navigation", () => {
1040
it("keeps the registered defaults while customization is unavailable", () => {
1141
expect(resolveWorkspaceTabOrder(undefined)).toEqual(["threads", "pullRequests", "usage"]);

‎apps/mobile/src/features/workspace/workspace-tabs-state.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,20 @@ export function workspaceTabsReducer(
102102
export const WORKSPACE_TOOLBAR = { height: 48, expandedGap: 10, edge: 16, gap: 8 };
103103
export const WORKSPACE_DOCK = { height: 48, tabsWidth: 176, gap: 12, bottomGap: 6 };
104104

105+
export function workspaceSearchBottomClearance(input: {
106+
readonly bottomInset: number;
107+
readonly bottomBarInset?: number;
108+
readonly keyboardHeight: number;
109+
}) {
110+
const bottom = input.bottomBarInset ?? Math.max(input.bottomInset, 12);
111+
// AboveKeyboard lifts the field to an 8-point gap above the keyboard.
112+
return (
113+
Math.max(bottom, input.keyboardHeight > 0 ? input.keyboardHeight + 8 : 0) +
114+
WORKSPACE_TOOLBAR.height +
115+
16
116+
);
117+
}
118+
105119
export function workspaceToolbarHeight(mode: WorkspaceSearchMode): number {
106120
return mode === "expanded"
107121
? WORKSPACE_TOOLBAR.height * 2 + WORKSPACE_TOOLBAR.expandedGap

0 commit comments

Comments
 (0)