Fix: 모달 닫힘 경고 팝업 뜨도록 수정 및 esc props 전달#198
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Walkthrough모달 공통 컴포넌트에 closeOnEsc 옵션을 추가하고 오버레이 클릭 기본값을 true로 변경했습니다. 작성 모달은 API 뮤테이션을 연동하고 ESC/오버레이로 닫힘을 비활성화했습니다. 경고 팝업은 onGoBack 훅을 추가해 되돌리기 동작을 커스터마이즈했습니다. 상세 모달에서는 불필요한 closeOnOverlayClick 지정이 제거되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as 사용자
participant WM as WriteModal
participant MU as useWriteLetter(뮤테이션)
participant PW as PopupWarningLetter
participant M as Modal
U->>WM: 닫기 클릭
WM->>WM: 내용/보낸이/이미지 여부 확인
alt 변경사항 존재
WM->>PW: 경고 팝업 열기
U->>PW: 돌아가기 클릭
PW-->>WM: onGoBack()
WM->>WM: 폼/이미지 리셋
WM->>M: onClose()
else 변경사항 없음
WM->>M: onClose()
end
U->>WM: 제출 클릭
WM->>MU: mutate({ capsuleId, content, from, objectKey })
MU-->>WM: 성공
WM->>M: onClose()
MU-->>WM: 실패
WM->>WM: 에러 처리(버튼 로딩 해제)
sequenceDiagram
autonumber
actor U as 사용자
participant M as Modal
Note over M: 공통 Modal 동작
U->>M: ESC 키
alt closeOnEsc=true AND isOpen
M->>M: onClose()
else closeOnEsc=false
M-->>U: 무시
end
U->>M: 오버레이 클릭
alt closeOnOverlayClick=true
M->>M: onClose()
else
M-->>U: 무시
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
|
This pull request (commit
|
🚀 Storybook 배포📖 Storybook: https://683d91ab23651aa0b399e435-agewjsicic.chromatic.com/ |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/(sub)/capsule-detail/_components/modal/index.tsx (1)
65-72: Enter/Space로 오버레이 닫힘이 closeOnOverlayClick 설정을 무시합니다
onKeyDown에서 Enter/Space 입력 시closeOnOverlayClick이false여도 닫히는 버그가 있습니다. 쓰기 모달처럼 오버레이 닫힘을 비활성화한 화면에서 키보드 조작으로 닫히는 문제가 생길 수 있어요. prop를 존중하도록 수정이 필요합니다. 스페이스 스크롤 방지를 위해preventDefault()도 권장합니다.- onKeyDown={(event) => { - if ( - (event.key === "Enter" || event.key === " ") && - event.target === event.currentTarget - ) { - onClose(); - } - }} + onKeyDown={(event) => { + if (event.target !== event.currentTarget) return; + if ((event.key === "Enter" || event.key === " ") && closeOnOverlayClick) { + event.preventDefault(); + onClose(); + } + }}
🧹 Nitpick comments (7)
shared/ui/popup/popup-warning-letter/index.tsx (2)
30-41: 버튼 type 명시로 의도치 않은 submit 방지Popup가 폼 문맥 내에서 재사용될 가능성을 고려하면 버튼에
type="button"을 명시하는 것이 안전합니다.- <Popup.Button onClick={onGoBack || close} className={styles.content}> + <Popup.Button type="button" onClick={onGoBack || close} className={styles.content}> 돌아가기 </Popup.Button> - <Popup.Button + <Popup.Button + type="button" className={styles.continueButton} onClick={(e) => { e.stopPropagation(); confirm(); }} >
9-10: onGoBack의 책임 명확화 또는 방어 로직 추가 검토현재는
onGoBack이 전달되면 팝업을 닫는 책임까지 호출자에게 있습니다. 다른 사용처에서onGoBack이 상태만 리셋하고 팝업 닫기를 누락하는 실수를 방지하려면, 컴포넌트 레벨에서 항상 닫히도록 방어하는 방법을 고려해주세요(중복 호출이어도 idempotent라면 안전).- <Popup.Button onClick={onGoBack || close} className={styles.content}> + <Popup.Button + type="button" + onClick={() => { + onGoBack?.(); + close(); + }} + className={styles.content} + >Also applies to: 16-17, 30-33
app/(sub)/capsule-detail/_components/modal/index.tsx (1)
40-46: body scroll lock 원복 시 기존 스타일 보존 제안
unset으로 고정 해제 시 기존 값이 덮여 의도치 않은 스크롤 상태가 될 수 있습니다(다중 모달/외부 스타일 개입). 이전 값을 저장해 정확히 복구하는 방식을 권장합니다.적용 예시(일부 발췌):
-import { useEffect } from "react"; +import { useEffect, useRef } from "react"; @@ export default function Modal({ @@ }: ModalProps) { + const prevOverflowRef = useRef<string>(); useEffect(() => { @@ - if (isOpen) { + if (isOpen) { + prevOverflowRef.current = document.body.style.overflow; if (closeOnEsc) { document.addEventListener("keydown", handleEscapeKey); } document.body.style.overflow = "hidden"; } @@ return () => { document.removeEventListener("keydown", handleEscapeKey); - document.body.style.overflow = "unset"; + document.body.style.overflow = + prevOverflowRef.current ?? ""; }; }, [isOpen, onClose, closeOnEsc]);app/(sub)/capsule-detail/_components/write-modal/index.tsx (4)
115-121: 제출 중에는 닫기 버튼도 비활성화 권장이중 액션/경합을 줄이려면
isPending || isUploading동안 닫기 버튼도 비활성화하는 것이 UX/안정성에 유리합니다.- <button + <button type="button" className={styles.closeButton} - onClick={handleCloseWithWarning} + onClick={handleCloseWithWarning} + disabled={isPending || isUploading} >
70-76: alert 대신 일관된 UI 컴포넌트 사용 제안브라우저
alert는 UI 톤 앤 매너를 해치고 제어가 어렵습니다. 기존 팝업/토스트 컴포넌트를 재사용하는 방식으로 교체를 권장합니다.
86-91: 에러 사용자 피드백 추가 필요
onError에서 콘솔 로깅만 하면 사용자는 실패를 인지하기 어렵습니다. 토스트/다이얼로그로 오류 사유를 안내해주세요(네트워크/서버 메시지 매핑).
239-261: 경고 팝업과의 연동 전반적으로 좋습니다 — reset 간소화 제안상태 초기화 후 닫기까지의 플로우가 자연스럽습니다. 폼 초기값이 이미
useForm의defaultValues로 정의되어 있으므로, 아래처럼reset()만 호출해 중복을 줄일 수 있습니다.onGoBack={() => { setIsWarningOpen(false); - reset({ - capsuleId: capsuleData.result.id.toString(), - content: "", - from: "", - objectKey: "", - }); + reset(); if (uploadedImageUrl) { removeImage(); } onClose(); }}
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
app/(sub)/capsule-detail/[invite-code]/[id]/letters/_components/letter-detail-modal/index.tsx(0 hunks)app/(sub)/capsule-detail/_components/modal/index.tsx(2 hunks)app/(sub)/capsule-detail/_components/write-modal/index.tsx(5 hunks)shared/ui/popup/popup-warning-letter/index.tsx(2 hunks)
💤 Files with no reviewable changes (1)
- app/(sub)/capsule-detail/[invite-code]/[id]/letters/_components/letter-detail-modal/index.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
app/(sub)/capsule-detail/_components/write-modal/index.tsx (1)
app/(sub)/capsule-detail/_components/modal/index.tsx (1)
Modal(19-83)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: test
- GitHub Check: deploy
- GitHub Check: storybook-deploy
🔇 Additional comments (5)
shared/ui/popup/popup-warning-letter/index.tsx (1)
33-39: 버블링 차단으로 상위 닫힘 트리거 방지, 좋습니다
e.stopPropagation()으로 상위 오버레이/모달 클릭 핸들러가 실행되지 않도록 한 점이 의도에 부합합니다.app/(sub)/capsule-detail/_components/modal/index.tsx (1)
29-40: ESC 핸들러 조건부 바인딩/클린업 적절함
closeOnEsc에 따라 리스너를 바인딩하고, 이펙트 클린업에서 항상 제거하는 방식은 안전합니다.deps에closeOnEsc포함한 점도 좋습니다.Also applies to: 47-47
app/(sub)/capsule-detail/_components/write-modal/index.tsx (3)
93-104: 내용 유무에 따른 경고 팝업 분기, 의도 정확합니다
stopPropagation()으로 모달 외부 닫힘 트리거를 차단하고, 실제 변경사항(본문/보내는 사람/이미지) 존재 시에만 경고를 띄우는 로직이 깔끔합니다.
107-113: 모달 잠금 설정(L1) OK — ESC/오버레이 닫힘 비활성화쓰기 모달의 특성상 닫힘을 제한한 설정이 합리적입니다. 단, 현재 Modal의 오버레이
onKeyDown이 Enter/Space에서closeOnOverlayClick을 무시하는 버그가 있으니(별도 코멘트 참고) 해당 수정이 반영되어야 완전한 잠금이 보장됩니다.
127-131: 로더 처리 및 비활성화 상태 연동 적절함전송/업로드 상태에 따라 스피너와 비활성화 처리하는 흐름이 명확합니다.
commit c07799a Merge: 0b2fa2b 6d6f73e Author: 백승범 <bdh3659@naver.com> Date: Sat Aug 23 00:58:43 2025 +0900 Merge branch 'develop' of https://github.com/YAPP-Github/26th-Web-Team-3-FE into qa/additional/#199 commit 0b2fa2b Author: 백승범 <bdh3659@naver.com> Date: Sat Aug 23 00:43:48 2025 +0900 style: grid-layout 모바일 view 수정 commit 278afe5 Author: 백승범 <bdh3659@naver.com> Date: Sat Aug 23 00:24:26 2025 +0900 fix: 편지 담기 reset 추가 commit 6d6f73e Author: beom <74394824+seung365@users.noreply.github.com> Date: Sat Aug 23 00:05:59 2025 +0900 fix: 모달 닫힘 경고 팝업 뜨도록 수정 및 esc props 전달 (#198)
* fix: 모달 닫힘 경고 팝업 뜨도록 수정 및 esc props 전달 * Squashed commit of the following: commit c07799a Merge: 0b2fa2b 6d6f73e Author: 백승범 <bdh3659@naver.com> Date: Sat Aug 23 00:58:43 2025 +0900 Merge branch 'develop' of https://github.com/YAPP-Github/26th-Web-Team-3-FE into qa/additional/#199 commit 0b2fa2b Author: 백승범 <bdh3659@naver.com> Date: Sat Aug 23 00:43:48 2025 +0900 style: grid-layout 모바일 view 수정 commit 278afe5 Author: 백승범 <bdh3659@naver.com> Date: Sat Aug 23 00:24:26 2025 +0900 fix: 편지 담기 reset 추가 commit 6d6f73e Author: beom <74394824+seung365@users.noreply.github.com> Date: Sat Aug 23 00:05:59 2025 +0900 fix: 모달 닫힘 경고 팝업 뜨도록 수정 및 esc props 전달 (#198) * fix: 모바일에서 간헐적으로 이미지 업로드 안되는 현상 수정 * feat: objectKey를 선택적 속성으로 변경 * feat: 사진 업로드 로직 변경 * chore: 줄간격 추가 * chore: type 충돌 해결 * chore: 코드 리뷰 반영
commit 03f9727 Author: 백승범 <bdh3659@naver.com> Date: Mon Aug 25 10:08:33 2025 +0900 chore: 코드 리뷰 반영 commit d62b829 Author: 백승범 <bdh3659@naver.com> Date: Mon Aug 25 09:54:19 2025 +0900 chore: type 충돌 해결 commit c3ee71d Author: 백승범 <bdh3659@naver.com> Date: Mon Aug 25 09:52:33 2025 +0900 chore: 줄간격 추가 commit 5232efc Merge: b62d9a4 a86f47b Author: 백승범 <bdh3659@naver.com> Date: Mon Aug 25 09:52:08 2025 +0900 Merge branch 'develop' of https://github.com/YAPP-Github/26th-Web-Team-3-FE into fix/input-image/#201 commit b62d9a4 Author: 백승범 <bdh3659@naver.com> Date: Mon Aug 25 09:37:31 2025 +0900 feat: 사진 업로드 로직 변경 commit a86f47b Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sun Aug 24 22:01:52 2025 +0000 Update all non-major dependencies (#202) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> commit ae76adb Author: 백승범 <bdh3659@naver.com> Date: Sun Aug 24 23:14:26 2025 +0900 feat: objectKey를 선택적 속성으로 변경 commit ae0638c Author: 백승범 <bdh3659@naver.com> Date: Sun Aug 24 22:47:50 2025 +0900 fix: 모바일에서 간헐적으로 이미지 업로드 안되는 현상 수정 commit b23c714 Author: beom <74394824+seung365@users.noreply.github.com> Date: Sat Aug 23 01:05:36 2025 +0900 QA: 추가 QA 반영 (#200) * fix: 모달 닫힘 경고 팝업 뜨도록 수정 및 esc props 전달 * fix: 편지 담기 reset 추가 * style: grid-layout 모바일 view 수정 commit 6d6f73e Author: beom <74394824+seung365@users.noreply.github.com> Date: Sat Aug 23 00:05:59 2025 +0900 fix: 모달 닫힘 경고 팝업 뜨도록 수정 및 esc props 전달 (#198)
commit 37dca81 Author: beom <74394824+seung365@users.noreply.github.com> Date: Mon Aug 25 12:48:52 2025 +0900 Fix: 이미지 관련 문의사항 해결 (#204) * fix: 모달 닫힘 경고 팝업 뜨도록 수정 및 esc props 전달 * Squashed commit of the following: commit c07799a Merge: 0b2fa2b 6d6f73e Author: 백승범 <bdh3659@naver.com> Date: Sat Aug 23 00:58:43 2025 +0900 Merge branch 'develop' of https://github.com/YAPP-Github/26th-Web-Team-3-FE into qa/additional/#199 commit 0b2fa2b Author: 백승범 <bdh3659@naver.com> Date: Sat Aug 23 00:43:48 2025 +0900 style: grid-layout 모바일 view 수정 commit 278afe5 Author: 백승범 <bdh3659@naver.com> Date: Sat Aug 23 00:24:26 2025 +0900 fix: 편지 담기 reset 추가 commit 6d6f73e Author: beom <74394824+seung365@users.noreply.github.com> Date: Sat Aug 23 00:05:59 2025 +0900 fix: 모달 닫힘 경고 팝업 뜨도록 수정 및 esc props 전달 (#198) * fix: 모바일에서 간헐적으로 이미지 업로드 안되는 현상 수정 * feat: objectKey를 선택적 속성으로 변경 * feat: 사진 업로드 로직 변경 * chore: 줄간격 추가 * chore: type 충돌 해결 * chore: 코드 리뷰 반영 commit 5c19df6 Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Mon Aug 25 00:53:03 2025 +0000 Update dev dependencies (#203) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> commit a86f47b Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Date: Sun Aug 24 22:01:52 2025 +0000 Update all non-major dependencies (#202) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> commit b23c714 Author: beom <74394824+seung365@users.noreply.github.com> Date: Sat Aug 23 01:05:36 2025 +0900 QA: 추가 QA 반영 (#200) * fix: 모달 닫힘 경고 팝업 뜨도록 수정 및 esc props 전달 * fix: 편지 담기 reset 추가 * style: grid-layout 모바일 view 수정 commit 6d6f73e Author: beom <74394824+seung365@users.noreply.github.com> Date: Sat Aug 23 00:05:59 2025 +0900 fix: 모달 닫힘 경고 팝업 뜨도록 수정 및 esc props 전달 (#198)
📌 Summary
📚 Tasks
👀 To Reviewer
아무 내용도 없을땐 popup이 뜨지 않고 바로 닫히도록 하였습니다. 또한 write-modal의 경우 esc로 닫히지 않게 했습니다.
📸 Screenshot
2025-08-22.11.48.20.mov
Summary by CodeRabbit
New Features
Bug Fixes