Skip to content

[feature] 자동 스크롤 훅 추가#988

Merged
seongwon030 merged 2 commits intodevelop-fefrom
feature/#987-scroll-to-top-MOA-465
Dec 29, 2025
Merged

[feature] 자동 스크롤 훅 추가#988
seongwon030 merged 2 commits intodevelop-fefrom
feature/#987-scroll-to-top-MOA-465

Conversation

@seongwon030
Copy link
Member

@seongwon030 seongwon030 commented Dec 28, 2025

#️⃣연관된 이슈

ex) #987

📝작업 내용

  • 어떤 페이지에서든 자동으로 상단 스크롤 되는 훅을 추가했습니다.

중점적으로 리뷰받고 싶은 부분(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

논의하고 싶은 부분(선택)

논의하고 싶은 부분이 있다면 작성해주세요.

🫡 참고사항

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • 페이지 탐색 시 자동으로 페이지 맨 위로 스크롤하는 기능이 추가되었습니다.
  • 리팩토링

    • 스크롤 감지 로직을 개선하고 최적화했습니다.
    • 불필요한 코드를 정리했습니다.

✏️ Tip: You can customize this high-level summary in your review settings.

@seongwon030 seongwon030 self-assigned this Dec 28, 2025
@seongwon030 seongwon030 added ✨ Feature 기능 개발 💻 FE Frontend labels Dec 28, 2025
@vercel
Copy link

vercel bot commented Dec 28, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
moadong Ready Ready Preview, Comment Dec 28, 2025 3:30pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 28, 2025

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Invalid regex pattern for base branch. Received: "**" at "reviews.auto_review.base_branches[0]"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

작업 내용 요약 (Walkthrough)

페이지 네비게이션 시 자동으로 상단으로 스크롤하는 기능을 추가합니다. 새로운 ScrollToTop 훅을 도입하고, 기존 스크롤 감지 훅을 명확한 이름으로 변경한 후 관련 컴포넌트를 업데이트합니다.

변경 사항 (Changes)

코호트 / 파일 변경 내용
스크롤 감지 훅 이름 변경
frontend/src/hooks/useScrollDetection.ts, frontend/src/components/common/Header/Header.tsx
useScroll 훅을 useScrollDetection으로 이름 변경하여 명확성 개선; Header 컴포넌트에서 훅 호출 업데이트; 주석 처리된 /patch-note nav 항목 제거
새로운 스크롤-투-톱 기능
frontend/src/hooks/ScrollToTop.tsx, frontend/src/App.tsx
라우트 경로 변경을 감지하여 페이지 상단으로 자동 스크롤하는 새로운 ScrollToTop 컴포넌트 추가; App 컴포넌트에 ScrollToTop 컴포넌트 렌더링 (ScrollToTopButton 앞에 배치)

예상 코드 리뷰 소요 시간

🎯 2 (Simple) | ⏱️ ~10 minutes

관련 이슈 (Possibly related issues)

  • MOA-465: 이 PR이 "페이지 이동 시 상단으로 자동스크롤된다" 요구사항을 직접 구현하며, 체크리스트의 "상단 스크롤훅 추가" 작업을 완료합니다.

관련 PR (Possibly related PRs)

추천 레이블 (Suggested labels)

🔨 Refactor

추천 리뷰어 (Suggested reviewers)

  • seongje973
  • oesnuj
  • lepitaaar

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목 '[feature] 자동 스크롤 훅 추가'는 변경사항의 핵심 내용인 스크롤 관련 훅 추가를 명확하게 요약하고 있습니다.
Linked Issues check ✅ Passed 모든 링크된 이슈(MOA-465)의 요구사항이 충족되었습니다: 페이지 이동 시 자동 스크롤 훅 구현 완료, App.tsx에 전역 설정.
Out of Scope Changes check ✅ Passed 모든 변경사항이 링크된 이슈의 범위 내입니다. Header.tsx의 useScroll 이름 변경은 훅 재명명의 일환이므로 범위 내입니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/#987-scroll-to-top-MOA-465

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
frontend/src/hooks/ScrollToTop.tsx (1)

7-9: 부드러운 스크롤 효과를 고려해보세요.

즉시 스크롤되는 것보다 behavior: 'smooth' 옵션을 사용하면 더 나은 사용자 경험을 제공할 수 있습니다.

🔎 부드러운 스크롤 적용 예시
  useEffect(() => {
-   window.scrollTo(0, 0);
+   window.scrollTo({ top: 0, left: 0, behavior: 'smooth' });
  }, [pathname]);

또는 접근성을 고려하여 사용자의 prefers-reduced-motion 설정을 존중하는 방법:

  useEffect(() => {
+   const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
+   window.scrollTo({ 
+     top: 0, 
+     left: 0, 
+     behavior: prefersReducedMotion ? 'auto' : 'smooth' 
+   });
-   window.scrollTo(0, 0);
  }, [pathname]);
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7516776 and b8b84a4.

📒 Files selected for processing (4)
  • frontend/src/App.tsx
  • frontend/src/components/common/Header/Header.tsx
  • frontend/src/hooks/ScrollToTop.tsx
  • frontend/src/hooks/useScrollDetection.ts
🧰 Additional context used
📓 Path-based instructions (3)
frontend/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (frontend/.cursorrules)

frontend/**/*.{ts,tsx,js,jsx}: Replace magic numbers with named constants for clarity
Replace complex/nested ternaries with if/else or IIFEs for readability
Assign complex boolean conditions to named variables for explicit meaning
Avoid hidden side effects; functions should only perform actions implied by their signature (Single Responsibility Principle)
Use unique and descriptive names for custom wrappers/functions to avoid ambiguity
Define constants near related logic or ensure names link them clearly to avoid silent failures
Break down broad state management into smaller, focused hooks/contexts to reduce coupling

Files:

  • frontend/src/App.tsx
  • frontend/src/hooks/ScrollToTop.tsx
  • frontend/src/hooks/useScrollDetection.ts
  • frontend/src/components/common/Header/Header.tsx
frontend/**/*.{tsx,jsx}

📄 CodeRabbit inference engine (frontend/.cursorrules)

frontend/**/*.{tsx,jsx}: Abstract complex logic/interactions into dedicated components/HOCs
Separate significantly different conditional UI/logic into distinct components
Colocate simple, localized logic or use inline definitions to reduce context switching
Choose field-level or form-level cohesion based on form requirements when using form libraries like react-hook-form
Use Component Composition instead of Props Drilling to reduce coupling

Files:

  • frontend/src/App.tsx
  • frontend/src/hooks/ScrollToTop.tsx
  • frontend/src/components/common/Header/Header.tsx
frontend/**/*.{ts,tsx}

📄 CodeRabbit inference engine (frontend/.cursorrules)

Use consistent return types for similar functions/hooks

Files:

  • frontend/src/App.tsx
  • frontend/src/hooks/ScrollToTop.tsx
  • frontend/src/hooks/useScrollDetection.ts
  • frontend/src/components/common/Header/Header.tsx
🧠 Learnings (6)
📚 Learning: 2025-11-25T14:08:23.253Z
Learnt from: CR
Repo: Moadong/moadong PR: 0
File: frontend/.cursorrules:0-0
Timestamp: 2025-11-25T14:08:23.253Z
Learning: Applies to frontend/**/*.{tsx,jsx} : Abstract complex logic/interactions into dedicated components/HOCs

Applied to files:

  • frontend/src/App.tsx
📚 Learning: 2025-11-25T14:08:23.253Z
Learnt from: CR
Repo: Moadong/moadong PR: 0
File: frontend/.cursorrules:0-0
Timestamp: 2025-11-25T14:08:23.253Z
Learning: Applies to frontend/**/*.{ts,tsx,js,jsx} : Break down broad state management into smaller, focused hooks/contexts to reduce coupling

Applied to files:

  • frontend/src/App.tsx
  • frontend/src/hooks/ScrollToTop.tsx
  • frontend/src/hooks/useScrollDetection.ts
📚 Learning: 2025-11-25T14:08:23.253Z
Learnt from: CR
Repo: Moadong/moadong PR: 0
File: frontend/.cursorrules:0-0
Timestamp: 2025-11-25T14:08:23.253Z
Learning: Applies to frontend/**/*.{tsx,jsx} : Colocate simple, localized logic or use inline definitions to reduce context switching

Applied to files:

  • frontend/src/App.tsx
📚 Learning: 2025-11-25T14:08:23.253Z
Learnt from: CR
Repo: Moadong/moadong PR: 0
File: frontend/.cursorrules:0-0
Timestamp: 2025-11-25T14:08:23.253Z
Learning: Applies to frontend/**/*.{tsx,jsx} : Use Component Composition instead of Props Drilling to reduce coupling

Applied to files:

  • frontend/src/App.tsx
  • frontend/src/components/common/Header/Header.tsx
📚 Learning: 2025-11-25T14:08:23.253Z
Learnt from: CR
Repo: Moadong/moadong PR: 0
File: frontend/.cursorrules:0-0
Timestamp: 2025-11-25T14:08:23.253Z
Learning: Applies to frontend/**/*.{ts,tsx} : Use consistent return types for similar functions/hooks

Applied to files:

  • frontend/src/hooks/useScrollDetection.ts
📚 Learning: 2025-11-25T14:08:23.253Z
Learnt from: CR
Repo: Moadong/moadong PR: 0
File: frontend/.cursorrules:0-0
Timestamp: 2025-11-25T14:08:23.253Z
Learning: Applies to frontend/**/*.{ts,tsx,js,jsx} : Replace magic numbers with named constants for clarity

Applied to files:

  • frontend/src/components/common/Header/Header.tsx
🧬 Code graph analysis (2)
frontend/src/App.tsx (1)
frontend/src/hooks/ScrollToTop.tsx (1)
  • ScrollToTop (4-12)
frontend/src/components/common/Header/Header.tsx (1)
frontend/src/hooks/useScrollDetection.ts (1)
  • useScrollDetection (3-16)
🔇 Additional comments (4)
frontend/src/App.tsx (1)

7-7: ScrollToTop 컴포넌트 통합이 적절합니다.

BrowserRouter 내부에 ScrollToTop을 배치한 것은 올바른 위치입니다. useLocation 훅이 정상적으로 작동하려면 라우터 컨텍스트 내부에 있어야 합니다.

Also applies to: 29-29

frontend/src/hooks/useScrollDetection.ts (1)

3-3: 훅 이름 변경이 명확성을 개선했습니다.

useScroll에서 useScrollDetection으로 변경하여 훅의 목적(스크롤 감지)을 더 명확하게 표현합니다.

frontend/src/components/common/Header/Header.tsx (1)

9-9: 훅 이름 업데이트가 올바르게 적용되었습니다.

useScrollDetection 훅 사용으로 정상적으로 업데이트되었으며, 기존 로직은 그대로 유지됩니다.

Also applies to: 18-18

frontend/src/hooks/ScrollToTop.tsx (1)

4-12: 컴포넌트 사용 권장은 이 프로젝트에 적용되지 않습니다.

현재 프로젝트는 React Router v7.1.1과 BrowserRouter를 사용하는 순수 React CSR SPA입니다. React Router v7의 <ScrollRestoration /> 컴포넌트는 데이터 로더를 사용하는 데이터 라우터(createBrowserRouter)에서만 작동하므로 BrowserRouter 구성에는 적용되지 않습니다.

현재 ScrollToTop 구현은 pathname 변경 시 페이지 최상단으로 스크롤하는 표준적인 CSR SPA 패턴이며, 이는 의도된 동작입니다. 코드베이스에 해시 네비게이션 사용 사례가 없으므로 해당 엣지 케이스는 실제 우려사항이 아닙니다.

Likely an incorrect or invalid review comment.

Copy link
Contributor

@lepitaaar lepitaaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

페이지 이동시 자동 스크롤 되게 변경하신거 좋네요!~

@seongwon030 seongwon030 merged commit fbf13b3 into develop-fe Dec 29, 2025
3 checks passed
@seongwon030 seongwon030 deleted the feature/#987-scroll-to-top-MOA-465 branch December 29, 2025 09:13
@seongwon030 seongwon030 linked an issue Dec 30, 2025 that may be closed by this pull request
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💻 FE Frontend ✨ Feature 기능 개발

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feature] MOA-465 페이지 이동 시 상단으로 자동스크롤된다

2 participants

Comments