Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(mobilehog): hide the keyboard when the drawer opens or the screen changes (#115145)

Dylan Martine192adf7b67d
diff --git a/products/desktop/apps/mobilehog/src/app/(drawer)/_layout.tsx b/products/desktop/apps/mobilehog/src/app/(drawer)/_layout.tsx
index 7f9fbf0bc238..4e3906aa055c 100644
--- a/products/desktop/apps/mobilehog/src/app/(drawer)/_layout.tsx
+++ b/products/desktop/apps/mobilehog/src/app/(drawer)/_layout.tsx
@@ -1,13 +1,29 @@
-import { Drawer } from "expo-router/drawer";
+import { Drawer, useDrawerStatus } from "expo-router/drawer";
+import { useEffect } from "react";
+import { Keyboard } from "react-native";
import { DrawerContent } from "@/components/DrawerContent";
import { colors, drawer } from "@/lib/theme";
+// The drawer only hides the keyboard on a swipe, and its screens stay mounted,
+// so a focused composer kept the keyboard up over the drawer and the next screen.
+function DismissKeyboardOnOpen(): null {
+ const open = useDrawerStatus() === "open";
+ useEffect(() => {
+ if (open) Keyboard.dismiss();
+ }, [open]);
+ return null;
+}
+
export default function DrawerLayout() {
return (
<Drawer
drawerContent={(props) => (
- <DrawerContent closeDrawer={() => props.navigation.closeDrawer()} />
+ <>
+ <DismissKeyboardOnOpen />
+ <DrawerContent closeDrawer={() => props.navigation.closeDrawer()} />
+ </>
)}
+ screenListeners={{ blur: () => Keyboard.dismiss() }}
screenOptions={{
headerShown: false,
drawerType: "back",