From 0196733be8d63087f33e3ae4a3b259f44af6a7a6 Mon Sep 17 00:00:00 2001 From: Philip Peterson <1326208+philip-peterson@users.noreply.github.com> Date: Mon, 8 Jun 2026 19:14:22 -0700 Subject: [PATCH] scroll --- .../riverside_pt/js/components/rpt-booking.js | 20 +++++++++++++++++-- web/modules/custom/riverside_pt/js/scroll.js | 13 ++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/web/modules/custom/riverside_pt/js/components/rpt-booking.js b/web/modules/custom/riverside_pt/js/components/rpt-booking.js index 63cc205..c735f7f 100644 --- a/web/modules/custom/riverside_pt/js/components/rpt-booking.js +++ b/web/modules/custom/riverside_pt/js/components/rpt-booking.js @@ -123,6 +123,9 @@ function BookingPanel({ service, settings }) { const selectedDateSlotsRef = useRef([]); const currentEventsRef = useRef([]); const initDate = useMemo(nextBusinessDay, []); + const formRef = useRef(null); + const prevSlotIdRef = useRef(null); + const successRef = useRef(null); function buildEventsUrl() { return settings.eventsUrl + "?service=" + service; @@ -273,6 +276,19 @@ function BookingPanel({ service, settings }) { } }, [fetchedEvents]); + useEffect(function () { + if (selectedSlotId && !prevSlotIdRef.current && formRef.current) { + window.rptScrollTo(formRef.current, true); + } + prevSlotIdRef.current = selectedSlotId; + }, [selectedSlotId]); + + useEffect(function () { + if (success && successRef.current) { + window.rptScrollTo(successRef.current, true); + } + }, [success]); + function handleSlotClick(slot) { setSelectedSlotId(slot.id); setSubmitError(null); @@ -373,7 +389,7 @@ function BookingPanel({ service, settings }) { ${!success && selectedSlot ? html` -