Skip to content

Commit f694a19

Browse files
t3dotggclaude
andauthored
feat(mobile): close the keyboard from the Duo's side bar (pingdotgg#24696)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 3e20b65 commit f694a19

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

‎apps/mobile/src/native/V5StackHeader.ios.tsx‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
} from "@react-navigation/native-stack";
66
import { isValidElement, useEffect, useRef } from "react";
77
import { StyleSheet } from "react-native";
8+
import { KeyboardController, useKeyboardState } from "react-native-keyboard-controller";
89
import { isDuoDevice } from "../lib/device-type";
910
import { useMobileNavigationTheme } from "../lib/useMobileNavigationTheme";
1011
import { useDeviceType, useNativeLayoutMetrics } from "../native/native-layout-metrics";
@@ -153,6 +154,7 @@ export function V5StackHeader(props: {
153154
const theme = useMobileNavigationTheme();
154155
const nativeMetrics = useNativeLayoutMetrics();
155156
const deviceType = useDeviceType();
157+
const keyboardVisible = useKeyboardState((state) => state.isVisible);
156158
const searchRef = useRef<SearchBarCommands>(null);
157159
const itemProps = { tintColor: options.headerTintColor, canGoBack: props.canGoBack };
158160
const leading = convertItems(options.unstable_headerLeftItems?.(itemProps) ?? [], "leading");
@@ -231,6 +233,28 @@ export function V5StackHeader(props: {
231233
trailing.push({ type: "spacer", id: "compose-group", sizing: "fixed", width: 8 });
232234
trailing.push(compose);
233235
}
236+
// The vertical bar has no keyboard accessory row, so it carries its own dismiss. A regular-width
237+
// primary column draws a horizontal bar beside the detail column's vertical one. The first
238+
// trailing item sits at the bar's far end; the flexible space keeps it next to the keyboard.
239+
if (
240+
keyboardVisible &&
241+
nativeMetrics &&
242+
nativeMetrics.verticalBarEdge !== "none" &&
243+
(props.column !== "primary" || nativeMetrics.horizontalSizeClass === "compact")
244+
) {
245+
trailing.unshift(
246+
{
247+
type: "item",
248+
id: "dismiss-keyboard",
249+
title: "Dismiss keyboard",
250+
icon: { type: "sfSymbol", name: "keyboard.chevron.compact.down" },
251+
onPress: () => void KeyboardController.dismiss(),
252+
// The folded bar is short; keep this out of the overflow menu.
253+
visibilityPriority: "high",
254+
},
255+
{ type: "spacer", id: "dismiss-keyboard-space", sizing: "flexible" },
256+
);
257+
}
234258
const left = options.headerLeft?.(itemProps);
235259
const right = options.headerRight?.(itemProps);
236260
if (!options.unstable_headerLeftItems && isValidElement(left))

0 commit comments

Comments
 (0)