diff --git a/packages/app/src/contexts/sidebar-animation-context.tsx b/packages/app/src/contexts/sidebar-animation-context.tsx index b1a1b5f83..1c321e0af 100644 --- a/packages/app/src/contexts/sidebar-animation-context.tsx +++ b/packages/app/src/contexts/sidebar-animation-context.tsx @@ -7,10 +7,11 @@ import { useRef, type ReactNode, } from "react"; -import { useWindowDimensions } from "react-native"; +import { Keyboard, useWindowDimensions } from "react-native"; import { useSharedValue, withTiming, Easing, type SharedValue } from "react-native-reanimated"; import { type GestureType } from "react-native-gesture-handler"; import { useIsCompactFormFactor } from "@/constants/layout"; +import { isNative } from "@/constants/platform"; import { selectIsAgentListOpen, usePanelStore } from "@/stores/panel-store"; import { getLeftSidebarAnimationTargets, @@ -65,11 +66,16 @@ export function SidebarAnimationProvider({ children }: { children: ReactNode }) const previousIsOpen = prevIsOpen.current; prevIsOpen.current = isOpen; prevWindowWidth.current = windowWidth; + const didOpen = !previousIsOpen && isOpen; if (!didStateChange) { return; } + if (didOpen && isCompactLayout && isNative) { + Keyboard.dismiss(); + } + // Gesture onEnd already started the animation on the UI thread — skip to avoid // a second competing withTiming that can desync translateX and backdropOpacity // after a provider remount (e.g. theme change). @@ -99,7 +105,7 @@ export function SidebarAnimationProvider({ children }: { children: ReactNode }) translateX.value = targets.translateX; backdropOpacity.value = targets.backdropOpacity; - }, [isOpen, translateX, backdropOpacity, windowWidth, isGesturing]); + }, [isOpen, translateX, backdropOpacity, windowWidth, isGesturing, isCompactLayout]); const animateToOpen = useCallback(() => { "worklet";