fix(dashboard): keep mobile chat input anchored under iOS keyboard
Suppress iOS auto-scroll-into-view on the chat textarea and lock body overflow while the keyboard is open so visualViewport.offsetTop stays zero and the composer remains pinned above the keyboard. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -834,20 +834,18 @@ export function ChatView({ projectId, addToast }: ChatViewProps) {
|
||||
}, [keyboardOverlap]);
|
||||
|
||||
// Lock body scroll on mobile while the keyboard is up so iOS can't shift
|
||||
// the visual viewport (offsetTop > 0) and push the input off the top.
|
||||
// the visual viewport (offsetTop > 0). Avoid forcing window.scrollTo(0, 0),
|
||||
// which can jump the page when send briefly toggles focus.
|
||||
useEffect(() => {
|
||||
if (!isMobile || !keyboardOpen) return;
|
||||
const scrollY = window.scrollY;
|
||||
const html = document.documentElement;
|
||||
const body = document.body;
|
||||
const prev = { htmlOverflow: html.style.overflow, bodyOverflow: body.style.overflow };
|
||||
window.scrollTo(0, 0);
|
||||
html.style.overflow = "hidden";
|
||||
body.style.overflow = "hidden";
|
||||
return () => {
|
||||
html.style.overflow = prev.htmlOverflow;
|
||||
body.style.overflow = prev.bodyOverflow;
|
||||
window.scrollTo(0, scrollY);
|
||||
};
|
||||
}, [isMobile, keyboardOpen]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user