From 15fe572205d32da3f4e5594e5805cc1f346e4db1 Mon Sep 17 00:00:00 2001 From: Dicken Date: Sat, 13 Jun 2026 19:52:39 +0200 Subject: [PATCH] fix: keyboard scroll nur wenn User bereits am Ende war --- frontend/src/tools/nachrichten.jsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/tools/nachrichten.jsx b/frontend/src/tools/nachrichten.jsx index 16d7ede..11714b0 100644 --- a/frontend/src/tools/nachrichten.jsx +++ b/frontend/src/tools/nachrichten.jsx @@ -227,12 +227,17 @@ export default function Nachrichten({ toast, mobile, nav }) { } }, [messages.length, activeUser?.id]); - // Wenn Handy-Tastatur aufklappt (visualViewport schrumpft) → ans Ende scrollen + // Wenn Handy-Tastatur aufklappt → ans Ende scrollen NUR wenn schon am Ende war useEffect(() => { if (!window.visualViewport) return; const onResize = () => { - // Kleine Verzögerung damit Layout neu berechnet wird - setTimeout(() => scrollToBottom('instant'), 50); + // Prüfe ob bottomRef nah am sichtbaren Bereich war (= User war am Ende) + if (!bottomRef.current) return; + const rect = bottomRef.current.getBoundingClientRect(); + const wasAtBottom = rect.top <= (window.visualViewport?.height ?? window.innerHeight) + 100; + if (wasAtBottom) { + setTimeout(() => scrollToBottom('instant'), 50); + } }; window.visualViewport.addEventListener('resize', onResize); return () => window.visualViewport.removeEventListener('resize', onResize);