From b93dcf151db5a99da7db749be357cb5b3efbede2 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Fri, 7 Nov 2025 07:45:07 -0600 Subject: [PATCH] add optional ref to always scroll to top the more filters in explore was not scrolled to the top on open due to the use of framer motion --- web/src/components/mobile/MobilePage.tsx | 18 +++++++++++++++++- .../overlay/dialog/PlatformAwareDialog.tsx | 13 +++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/web/src/components/mobile/MobilePage.tsx b/web/src/components/mobile/MobilePage.tsx index b5084d65a..a4b80b2cb 100644 --- a/web/src/components/mobile/MobilePage.tsx +++ b/web/src/components/mobile/MobilePage.tsx @@ -4,6 +4,7 @@ import { useEffect, useState, useCallback, + useRef, } from "react"; import { createPortal } from "react-dom"; import { motion, AnimatePresence } from "framer-motion"; @@ -121,17 +122,20 @@ export function MobilePagePortal({ type MobilePageContentProps = { children: React.ReactNode; className?: string; + scrollerRef?: React.RefObject; }; export function MobilePageContent({ children, className, + scrollerRef, }: MobilePageContentProps) { const context = useContext(MobilePageContext); if (!context) throw new Error("MobilePageContent must be used within MobilePage"); const [isVisible, setIsVisible] = useState(context.open); + const containerRef = useRef(null); useEffect(() => { if (context.open) { @@ -140,15 +144,27 @@ export function MobilePageContent({ }, [context.open]); const handleAnimationComplete = () => { - if (!context.open) { + if (context.open) { + // After opening animation completes, ensure scroller is at the top + if (scrollerRef?.current) { + scrollerRef.current.scrollTop = 0; + } + } else { setIsVisible(false); } }; + useEffect(() => { + if (context.open && scrollerRef?.current) { + scrollerRef.current.scrollTop = 0; + } + }, [context.open, scrollerRef]); + return ( {isVisible && ( (null); + if (isMobile) { return ( @@ -87,14 +90,20 @@ export function PlatformAwareSheet({ {trigger} - + onOpenChange(false)} > {title} -
+
{content}