refactor: 스크롤 복원 공용화 및 토너먼트 아카이브 적용 - #408
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Discord 스레드 연동용 메타데이터입니다. discord-pr-bot 워크플로가 자동 생성하며, 수정·삭제하면 PR 과 Discord 알림 연동이 끊깁니다. |
📝 WalkthroughWalkthrough스크롤 복원 로직을 공용 유틸리티와 훅으로 이동했습니다. 위시리스트는 공용 네임스페이스를 사용합니다. 토너먼트 아카이브는 탭별 복원과 history state 보존을 지원합니다. Changes스크롤 복원 공용 기반
위시리스트 스크롤 복원 전환
토너먼트 탭별 스크롤 복원
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/web/src/app/archive/tournament/_components/TournamentHistoryList.tsx (1)
12-17: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winProps 타입 이름을 컴포넌트 이름으로 지정하세요.
Props를TournamentHistoryListProps로 변경하세요. 이 이름은 다른 컴포넌트의 props 타입과 구분되지 않습니다.수정 예시
-type Props = { +type TournamentHistoryListProps = { statuses: TournamentStatusT[]; statusTab: TournamentStatusTabT; }; -function TournamentHistoryList({ statuses, statusTab }: Props) { +function TournamentHistoryList({ statuses, statusTab }: TournamentHistoryListProps) {As per coding guidelines: Props 타입은
{ComponentName}Props로 명명해야 합니다.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/app/archive/tournament/_components/TournamentHistoryList.tsx` around lines 12 - 17, Rename the Props type used by TournamentHistoryList to TournamentHistoryListProps and update the component’s parameter annotation to reference the renamed type, following the {ComponentName}Props convention.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@apps/web/src/app/archive/tournament/_components/TournamentHistorySection.tsx`:
- Around line 20-23: Update handleTabChange so it constructs a URL from the
current location, changes only the tab query parameter, and passes the resulting
pathname, search, and hash to window.history.replaceState. Preserve all existing
query parameters and the URL hash while updating the active tab.
In `@apps/web/src/utils/scrollRestoration.ts`:
- Line 40: Update getScrollContainer and the related scroll save/restore flow to
accept a ScrollRestorationTargetT-specific container reference or resolver
instead of always using SCROLL_CONTAINER_ID. Ensure TournamentHistorySection’s
overflow-y-auto container is selected, and use that same resolved container for
both saving and restoring offsets.
---
Nitpick comments:
In `@apps/web/src/app/archive/tournament/_components/TournamentHistoryList.tsx`:
- Around line 12-17: Rename the Props type used by TournamentHistoryList to
TournamentHistoryListProps and update the component’s parameter annotation to
reference the renamed type, following the {ComponentName}Props convention.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 16a2c47c-22bc-4c45-8175-44f78acce3a9
📒 Files selected for processing (9)
apps/web/src/app/archive/tournament/_components/TournamentHistoryList.tsxapps/web/src/app/archive/tournament/_components/TournamentHistorySection.tsxapps/web/src/app/archive/wish/_components/WishlistList.tsxapps/web/src/app/archive/wish/_components/wish-grid/index.tsxapps/web/src/app/archive/wish/_hooks/useScrollRestoration.tsapps/web/src/app/archive/wish/_utils/wishScroll.tsapps/web/src/components/tournament-card/index.tsxapps/web/src/hooks/useScrollRestoration.tsapps/web/src/utils/scrollRestoration.ts
💤 Files with no reviewable changes (2)
- apps/web/src/app/archive/wish/_hooks/useScrollRestoration.ts
- apps/web/src/app/archive/wish/_utils/wishScroll.ts
작업 요약
작업 세부 내용
#392 에서 구현한 스크롤 복원은 로직 자체는 범용적이지만 저장 키·타입·파일 위치가 위시에 종속되어 있었습니다. 토너먼트 아카이브에도 적용하기 위해 공용화했습니다.
토너먼트 페이지 구조에서 전제가 다른 지점들이 있어 그 부분을 함께 해결했습니다.
1. 공용 모듈로 분리
app/archive/wish/_utils/wishScroll.tssrc/utils/scrollRestoration.tsapp/archive/wish/_hooks/useScrollRestoration.tssrc/hooks/useScrollRestoration.tsnamespace— 리스트 구분자. 저장·복원이 같은 키를 쓰도록SCROLL_NAMESPACE상수로 관리scope— 같은 history entry 안에서 위치가 나뉘는 경우의 하위 구분자 (탭 등)piki:scroll:{namespace}:{scope}:{entryKey}data-wish-id→data-scroll-anchor-id,wishId→anchorId로 중립화로직(history entry 도장으로 뒤로가기 판별, 복원 성공 시 저장값 삭제, rAF 재시도)은 #392 에서 그대로 옮겼습니다.
2. 탭별 스크롤 위치 분리
토너먼트 아카이브는 진행 중 / 완료 탭이 하나의 history entry 를 공유합니다.
(탭 전환이 라우팅이 아니라
useState+replaceState로 처리됨)entry 당 저장값이 하나면 탭을 오갈 때 다른 탭의 위치로 복원되므로, 탭을
scope로 넘겨 저장 키를 분리했습니다.3. history.state 보존
TournamentHistorySection은 서버 요청 없이 URL만 동기화하기 위해 history.replaceState를 사용하고 있었는데, state에 null을 전달하면서 기존 history.state가 덮어써지고 있었습니다.
스크롤 복원은 history.state에 저장한 식별자를 기준으로 동일한 history entry를 판별하므로, 기존 state를 유지하도록 수정했습니다.
또한 history.state에는 Next 라우터의 내부 라우팅 정보(__NA, 라우팅 트리 등)도 포함되어 있어, 기존 값을 보존하는 편이 더 안전합니다.
4. 카드 링크 구조 차이
위시는
<Link>가 카드를 감싸지만, 토너먼트 카드는 카드 안에 오버레이 링크가 있습니다. 저장(클릭)과 복원(속성 조회)이 같은 요소를 기준으로 측정해야 위치가 맞으므로,data-scroll-anchor-id와onClick을 모두 오버레이 링크에 붙였습니다.연관 이슈
closes #407
Summary by CodeRabbit