From 63b8d5bc1e5827be08d32879b849ddf3ccb03ab3 Mon Sep 17 00:00:00 2001 From: nodeJun Date: Thu, 27 Nov 2025 14:32:26 +0900 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=EC=8A=A4=ED=81=AC=EB=A1=A4=20?= =?UTF-8?q?=ED=95=B8=EB=93=A4=20=EB=B2=84=EA=B7=B8=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/entities/chat/model/useUnreadMessageScroll.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/entities/chat/model/useUnreadMessageScroll.ts b/frontend/src/entities/chat/model/useUnreadMessageScroll.ts index f82a80a2..6ed2dbb2 100644 --- a/frontend/src/entities/chat/model/useUnreadMessageScroll.ts +++ b/frontend/src/entities/chat/model/useUnreadMessageScroll.ts @@ -114,7 +114,7 @@ export function useUnreadMessageScroll({ if (scrollRef.current && (shouldScrollToBottom || isNearBottom)) { scrollRef.current.scrollTop = scrollRef.current.scrollHeight; } - }, [messages, shouldScrollToBottom, hasScrolledToUnread, isNearBottom]); + }, [messages.length, shouldScrollToBottom, hasScrolledToUnread, isNearBottom]); // 스크롤 이벤트 핸들러: 사용자가 맨 아래 근처에 있는지 확인 const handleScroll = () => { @@ -129,6 +129,11 @@ export function useUnreadMessageScroll({ const isUserNearBottom = scrollBottom < 100; setIsNearBottom(isUserNearBottom); + + // ✅ 사용자가 위로 스크롤하면 자동 스크롤 비활성화 + if (!isUserNearBottom) { + setShouldScrollToBottom(false); + } }; // 읽지 않은 메시지 마커를 표시할지 결정