-
Notifications
You must be signed in to change notification settings - Fork 2
채팅 컴포넌트 UX 개선 - 새 메시지 알림 및 스크롤 가이드 버튼 구현 #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
- 마지막 메세지를 맨 아래에 띄우도록 absolute 적용
- NewMessage sender 추가, icon 삭제
Summary of ChangesHello @kim-hyunjoo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 채팅 컴포넌트의 사용자 경험을 개선하는 데 중점을 둡니다. 사용자가 채팅 기록을 탐색하는 동안 새로운 메시지를 놓치지 않도록 시각적인 알림과 편리한 스크롤 기능을 제공하여, 채팅 흐름을 보다 직관적이고 효율적으로 관리할 수 있도록 합니다. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
채팅 컴포넌트의 UX를 개선하기 위한 좋은 변경 사항입니다. 새로운 메시지 알림 및 자동 스크롤 기능이 추가되었네요. 전반적으로 잘 구현되었지만, 코드의 안정성과 유지보수성을 높이기 위해 몇 가지 개선점을 제안합니다. 주요 내용은 useEffect
훅의 의존성 관리, 리스트 렌더링 시 key
사용법, 그리고 사소한 코드 스타일 관련입니다. 자세한 내용은 각 파일의 주석을 확인해주세요.
useEffect(() => { | ||
//@TODO: 추후에 채팅을 실시간으로 보고 있을 때는 자동 스크롤, 위 채팅을 보고 있을 때는 자동 스크롤이 안되도록 기능 수정 | ||
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }); | ||
}, [chatMessages]); | ||
if (chatMessages.length === 0) return; | ||
|
||
const lastMessage = chatMessages[chatMessages.length - 1]; | ||
const isSentByMe = lastMessage.sender === myName; | ||
const container = messagesContainerRef.current; | ||
|
||
if (!isAtBottom) { | ||
setShowNewMessage(true); | ||
} | ||
|
||
if (container && (isSentByMe || isAtBottom)) { | ||
container.scrollTop = container.scrollHeight; | ||
} | ||
handleScroll(); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [chatMessages, myName, handleScroll]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요! 새 메시지 알림 기능 구현을 위한 좋은 변경입니다. 다만 이 useEffect
훅의 안정성을 높이기 위해 몇 가지 개선점을 제안합니다.
- UI 깜빡임 (Flicker): 현재 코드에서는 스크롤을 위로 올린 상태에서 내가 메시지를 보내면 '새 메시지' 알림이 아주 잠깐 보였다가 사라지는 현상이 발생합니다.
eslint-disable
주석:react-hooks/exhaustive-deps
규칙을 비활성화하면,useEffect
가 오래된isAtBottom
값을 참조하여 예기치 않은 동작을 일으킬 수 있습니다(stale closure).
아래와 같이 setShowNewMessage
호출 조건을 수정하면 깜빡임 현상을 해결할 수 있습니다. eslint-disable
문제는 더 근본적인 리팩토링(예: useRef
사용)이 필요할 수 있지만, 우선 급한 UX 버그부터 수정하는 것이 좋습니다.
if (!isAtBottom && !isSentByMe) {
setShowNewMessage(true);
}
if (container && (isSentByMe || isAtBottom)) {
container.scrollTop = container.scrollHeight;
}
handleScroll();
// eslint-disable-next-line react-hooks/exhaustive-deps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
완료
isAtBottom이 배열에 들어가면 스크롤이 아래로 계속 고정되므로 반영x
src/components/Chatting/Chatting.tsx
Outdated
> | ||
{chatMessages.map((item, index) => ( | ||
<Item | ||
key={index} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
완료
variant="secondary" | ||
> | ||
<p className="text-body3 overflow-hidden text-ellipsis whitespace-nowrap"> | ||
{sender != 'system' && `${sender}: `} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
완료
📝작업 내용
📷스크린샷(필요 시)
KakaoTalk_Video_2025-10-10-18-01-01.mp4
✨PR Point