From 6fdc4d8fb8e0879e76e4061ac1fc85f852529b31 Mon Sep 17 00:00:00 2001 From: syc0123 Date: Tue, 31 Mar 2026 16:23:05 +0900 Subject: [PATCH] =?UTF-8?q?[RAPID-fix]=20=EC=8A=A4=ED=81=AC=EB=A1=A4=20?= =?UTF-8?q?=EA=B7=BC=EB=B3=B8=20=EC=9B=90=EC=9D=B8=20=EC=88=98=EC=A0=95:?= =?UTF-8?q?=20isOpen=20deps=20=EC=B6=94=EA=B0=80=EB=A1=9C=20=EB=A9=94?= =?UTF-8?q?=EC=8B=A0=EC=A0=80=20=EC=97=B4=EB=A6=B4=20=EB=95=8C=EB=A7=88?= =?UTF-8?q?=EB=8B=A4=20=ED=95=98=EB=8B=A8=20=EC=8A=A4=ED=81=AC=EB=A1=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/components/messenger/ChatPanel.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/components/messenger/ChatPanel.tsx b/frontend/components/messenger/ChatPanel.tsx index 784f6561..8b7543ec 100644 --- a/frontend/components/messenger/ChatPanel.tsx +++ b/frontend/components/messenger/ChatPanel.tsx @@ -16,7 +16,7 @@ interface ChatPanelProps { export function ChatPanel({ room }: ChatPanelProps) { const { user } = useAuth(); - const { selectedRoomId } = useMessengerContext(); + const { selectedRoomId, isOpen } = useMessengerContext(); const { data: messages } = useMessages(selectedRoomId); const markAsRead = useMarkAsRead(); const updateRoom = useUpdateRoom(); @@ -38,14 +38,15 @@ export function ChatPanel({ room }: ChatPanelProps) { // Scroll to bottom: sentinel scrollIntoView before paint (no visible jump) useLayoutEffect(() => { - bottomRef.current?.scrollIntoView(); - }, [selectedRoomId, lastMessageId]); + if (isOpen) bottomRef.current?.scrollIntoView(); + }, [selectedRoomId, lastMessageId, isOpen]); // Second pass for async image loads useEffect(() => { + if (!isOpen) return; const t = setTimeout(() => { bottomRef.current?.scrollIntoView(); }, 600); return () => clearTimeout(t); - }, [lastMessageId, selectedRoomId]); + }, [lastMessageId, selectedRoomId, isOpen]); // Re-attach scroll listener whenever room changes (scrollRef mounts after room is set) useEffect(() => {