From 6d002bf762601a361a2260648972ff530b3b7561 Mon Sep 17 00:00:00 2001 From: Aaron Benmohan John Date: Fri, 22 May 2026 21:40:32 +0530 Subject: [PATCH 1/2] fix(scroll): hide when scroll-to-top is clicked --- .../components/layout/footer/ScrollToTop.tsx | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/frontend/src/ts/components/layout/footer/ScrollToTop.tsx b/frontend/src/ts/components/layout/footer/ScrollToTop.tsx index c737bf914b16..ca0afeb6329d 100644 --- a/frontend/src/ts/components/layout/footer/ScrollToTop.tsx +++ b/frontend/src/ts/components/layout/footer/ScrollToTop.tsx @@ -5,14 +5,27 @@ import { Fa } from "../../common/Fa"; export function ScrollToTop(): JSXElement { const [visible, setVisible] = createSignal(false); + const [scrolling, setScrolling] = createSignal(false); const handleScroll = (): void => { - if (getActivePage() === "test") return; + if (getActivePage() === "test" || scrolling()) return; const scroll = window.scrollY; setVisible(scroll > 100); }; + const scrollUp = async (): Promise => { + const scrollEnded = new Promise((resolve) => { + if (window.scrollY === 0) { + resolve(); + return; + } + window.addEventListener("scrollend", () => resolve(), { once: true }); + }); + window.scrollTo({ top: 0, behavior: "smooth" }); + await scrollEnded; + }; + onMount(() => { window.addEventListener("scroll", handleScroll, { passive: true }); handleScroll(); @@ -35,12 +48,11 @@ export function ScrollToTop(): JSXElement { "opacity-0": getActivePage() === "test" || !visible(), "pointer-events-none": getActivePage() === "test" || !visible(), }} - onClick={() => { + onClick={async () => { setVisible(false); - window.scrollTo({ - top: 0, - behavior: "smooth", - }); + setScrolling(true); + await scrollUp(); + setScrolling(false); }} > From b1915eb3023f9c2fd45ac0ff323a7a6ab1ba901c Mon Sep 17 00:00:00 2001 From: ares?? <146799833+AzureNightlock@users.noreply.github.com> Date: Fri, 22 May 2026 21:43:37 +0530 Subject: [PATCH 2/2] use inline if --- frontend/src/ts/components/layout/footer/ScrollToTop.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/frontend/src/ts/components/layout/footer/ScrollToTop.tsx b/frontend/src/ts/components/layout/footer/ScrollToTop.tsx index ca0afeb6329d..9b846423644c 100644 --- a/frontend/src/ts/components/layout/footer/ScrollToTop.tsx +++ b/frontend/src/ts/components/layout/footer/ScrollToTop.tsx @@ -16,10 +16,7 @@ export function ScrollToTop(): JSXElement { const scrollUp = async (): Promise => { const scrollEnded = new Promise((resolve) => { - if (window.scrollY === 0) { - resolve(); - return; - } + if (window.scrollY === 0) return resolve(); window.addEventListener("scrollend", () => resolve(), { once: true }); }); window.scrollTo({ top: 0, behavior: "smooth" });