From 3d89364f453070c20d79913e98c095ba56554a7f Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Thu, 22 Jan 2026 23:43:44 +0000 Subject: [PATCH] Changes --- src/pages/AIChat.tsx | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/pages/AIChat.tsx b/src/pages/AIChat.tsx index 04d19d5..14f7aa1 100644 --- a/src/pages/AIChat.tsx +++ b/src/pages/AIChat.tsx @@ -1,4 +1,5 @@ import { useState, useRef, useEffect } from 'react'; +import { createPortal } from 'react-dom'; import { motion } from 'framer-motion'; import { Send, Bot, User, Loader2, Trash2, AlertTriangle, Maximize2, Minimize2, ChevronDown, Settings } from 'lucide-react'; import { Button } from '@/components/ui/button'; @@ -108,6 +109,18 @@ const AIChat = () => { const isMobile = typeof window !== 'undefined' && window.innerWidth < 768; const { enterFullscreen, exitFullscreen } = useBrowserFullscreen(); + // Prevent page scroll while in fullscreen mode (portal overlays the viewport) + useEffect(() => { + if (typeof document === 'undefined') return; + if (!isFullscreen) return; + + const prevOverflow = document.body.style.overflow; + document.body.style.overflow = 'hidden'; + return () => { + document.body.style.overflow = prevOverflow; + }; + }, [isFullscreen]); + // Exit fullscreen on Escape key useEffect(() => { const handleEscape = (e: KeyboardEvent) => { @@ -382,16 +395,16 @@ const AIChat = () => { sendMessage(); } }; - return ( + const chatUi = (
{ ); + + // IMPORTANT: MainLayout uses framer-motion transforms which create a containing block + // for `position: fixed` descendants, causing "fullscreen" to be clipped. + // Portaling to body guarantees true viewport fullscreen. + return isFullscreen && typeof document !== 'undefined' + ? createPortal(chatUi, document.body) + : chatUi; }; export default AIChat;