From cbb8d59639abab13743ab42cde96d9f090d32cd4 Mon Sep 17 00:00:00 2001 From: Dicken Date: Sat, 13 Jun 2026 18:28:36 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20ScrollToTop=20h=C3=B6rt=20auf=20window?= =?UTF-8?q?=20+=20Ref,=20main=20bekommt=20height:100vh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/App.jsx | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 56fd27e..7901790 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -3220,18 +3220,33 @@ function ScrollToTop({ scrollRef }) { const [visible, setVisible] = useState(false); useEffect(() => { + // Prüfe sowohl window als auch den Ref-Container const el = scrollRef?.current; - if (!el) return; - const onScroll = () => setVisible(el.scrollTop > 300); - el.addEventListener('scroll', onScroll, { passive: true }); - return () => el.removeEventListener('scroll', onScroll); + + function check() { + const winScroll = window.scrollY || document.documentElement.scrollTop; + const elScroll = el ? el.scrollTop : 0; + setVisible(winScroll > 300 || elScroll > 300); + } + + window.addEventListener('scroll', check, { passive: true }); + if (el) el.addEventListener('scroll', check, { passive: true }); + return () => { + window.removeEventListener('scroll', check); + if (el) el.removeEventListener('scroll', check); + }; }, [scrollRef]); + function scrollUp() { + window.scrollTo({ top: 0, behavior: 'smooth' }); + if (scrollRef?.current) scrollRef.current.scrollTo({ top: 0, behavior: 'smooth' }); + } + if (!visible) return null; return (