[refactor] 지원자 탭 확장을 위한 공통 검색창 통일#647
Conversation
- SearchField.styles.ts 도입으로 페이지 전용 스타일 의존 제거 - SearchField가 공통 스타일을 직접 참조하도록 변경 - 검색 입력 UI의 재사용성/일관성 향상
|
Warning
|
| Cohort / File(s) | Summary |
|---|---|
Header import 경로 업데이트frontend/src/components/common/Header/Header.tsx |
SearchBox import 경로를 @/pages/MainPage/components/SearchBox/SearchBox로 변경. |
공통 SearchBox 제거frontend/src/components/common/SearchBox/SearchBox.tsx |
기존 공통 SearchBox 컴포넌트 파일 삭제. |
공통 SearchField 추가frontend/src/components/common/SearchField/SearchField.tsx |
재사용 가능한 제어형 검색 입력 컴포넌트 추가(값/변경/제출/placeholder/aria/autoBlur 지원). |
메인 페이지용 SearchBox 추가frontend/src/pages/MainPage/components/SearchBox/SearchBox.tsx |
컨텍스트(Search/Category) 및 트래킹 연동, 홈 리다이렉트 포함한 검색 제출 로직 구현. UI는 공통 SearchField 사용. |
Sequence Diagram(s)
sequenceDiagram
actor User
User->>Header: 입력 및 제출
Header->>MainPage SearchBox: onSubmit 호출
MainPage SearchBox->>Router: 홈('/')로 이동(필요 시)
MainPage SearchBox->>SearchContext: setKeyword(inputValue), setIsSearching(true)
MainPage SearchBox->>CategoryContext: setSelectedCategory('all')
MainPage SearchBox->>Tracker: "Search Executed" 이벤트 기록
MainPage SearchBox->>SearchField: value/onChange 전달
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| 공통 검색창 도입 및 사용처 정리 (MOA-153) | ✅ |
Assessment against linked issues: Out-of-scope changes
(해당 없음)
Possibly related issues
- #645: 공통 SearchField 도입 및 기존 SearchBox 대체와 일치.
- [feature] MOA-154 지원자를 검색할 수 있다 #648: 지원자 검색 UI를 공통 SearchField로 전환 과제와 직접적으로 부합.
- #643: SearchBox를 페이지 전용으로 이동하고 공통 컴포넌트를 도입하는 리팩터와 동일한 방향.
- [refactor] MOA-153 지원자 탭 확장을 위한 공통 검색창 도입 #646: 공통 검색 필드 리팩터링과 목적이 동일.
Possibly related PRs
- [feature] 검색 시 전체동아리 기준으로 검색된다 #616: SearchBox의 검색 상태 처리(setIsSearching, 카테고리 리셋) 변경과 직접 연관.
- [refactor] Header 컴포넌트 리팩터링 - View와 service 로직 분리 및 선언 순서 개선 #340: Header에서 SearchBox 사용/경로 조정과 관련된 변경점 공유.
Suggested reviewers
- Zepelown
- oesnuj
- lepitaaar
✨ Finishing Touches
- 📝 Generate Docstrings
🧪 Generate unit tests
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
refactor/#646-common-search-filed-MOA-153
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.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. - PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
CodeRabbit Commands (Invoked using PR/Issue comments)
Type @coderabbitai help to get the list of available commands.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Status, Documentation and Community
- Visit our Status Page to check the current availability of CodeRabbit.
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
frontend/src/pages/MainPage/components/SearchBox/SearchBox.tsx (1)
14-18: 홈 리다이렉션 로직을 단순화할 수 있습니다.현재 구현은 올바르지만, React Router의
navigate함수는 이미 현재 경로와 동일한 경로로 이동할 때 자동으로 처리하므로 조건문이 불필요할 수 있습니다.다음과 같이 단순화할 수 있습니다:
- const redirectToHome = () => { - if (location.pathname !== '/') { - navigate('/'); - } - }; + const redirectToHome = () => { + navigate('/'); + };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
frontend/src/components/common/Header/Header.tsx(1 hunks)frontend/src/components/common/SearchBox/SearchBox.tsx(0 hunks)frontend/src/components/common/SearchField/SearchField.tsx(1 hunks)frontend/src/pages/MainPage/components/SearchBox/SearchBox.tsx(1 hunks)
💤 Files with no reviewable changes (1)
- frontend/src/components/common/SearchBox/SearchBox.tsx
🧰 Additional context used
📓 Path-based instructions (2)
frontend/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (frontend/.cursorrules)
frontend/**/*.{ts,tsx}: Replace magic numbers with named constants for clarity.
Replace complex or nested ternary operators with if/else statements or IIFEs for readability.
Assign complex boolean conditions to named variables.
Use consistent return types for similar functions and hooks.
Avoid hidden side effects; functions should only perform actions implied by their signature (Single Responsibility Principle).
Use unique, descriptive names for custom wrappers and functions to avoid ambiguity.
Define constants near related logic or ensure names link them clearly.
Files:
frontend/src/pages/MainPage/components/SearchBox/SearchBox.tsxfrontend/src/components/common/Header/Header.tsxfrontend/src/components/common/SearchField/SearchField.tsx
frontend/**/*.tsx
📄 CodeRabbit Inference Engine (frontend/.cursorrules)
frontend/**/*.tsx: Abstract complex logic/interactions into dedicated components or higher-order 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.
Break down broad state management into smaller, focused hooks or contexts.
Use component composition instead of props drilling.
Files:
frontend/src/pages/MainPage/components/SearchBox/SearchBox.tsxfrontend/src/components/common/Header/Header.tsxfrontend/src/components/common/SearchField/SearchField.tsx
🔇 Additional comments (9)
frontend/src/pages/MainPage/components/SearchBox/SearchBox.tsx (3)
1-12: 의존성 가져오기가 잘 구성되어 있습니다.필요한 모든 훅과 컴포넌트를 적절히 가져왔고, 코드 구조가 명확합니다.
20-30: 검색 핸들러 로직이 올바르게 구현되었습니다.검색 실행 시 홈으로 이동, 카테고리 초기화, 검색 상태 설정, 그리고 Mixpanel 이벤트 추적이 모두 적절히 처리되었습니다.
32-41: SearchField 컴포넌트 사용이 적절합니다.재사용 가능한 SearchField 컴포넌트를 사용하여 관심사를 잘 분리했고, 한국어 플레이스홀더와 접근성 라벨이 적절히 설정되었습니다.
frontend/src/components/common/Header/Header.tsx (1)
3-3: SearchBox 가져오기 경로가 올바르게 업데이트되었습니다.공통 컴포넌트에서 페이지별 컴포넌트로 이동한 것이 적절하며, 가져오기 경로가 정확히 변경되었습니다.
frontend/src/components/common/SearchField/SearchField.tsx (5)
5-12: 인터페이스 정의가 명확하고 타입 안전성이 보장됩니다.모든 필수 및 선택적 프로퍼티가 적절히 정의되었고, 기본값 설정도 합리적입니다.
14-21: 기본 매개변수 설정이 적절합니다.한국어 기본 플레이스홀더와 접근성 라벨이 적절하며,
autoBlur기본값도 합리적입니다.
22-24: 상태 관리가 올바르게 구현되었습니다.포커스 상태 추적과 입력 참조 설정이 적절합니다.
25-29: 폼 제출 핸들러가 올바르게 구현되었습니다.기본 이벤트 방지, 콜백 호출, 그리고 조건부 블러 처리가 모두 적절히 구현되었습니다.
31-52: 렌더링 로직과 접근성이 잘 구현되었습니다.스타일드 컴포넌트를 사용한 조건부 스타일링, 적절한 이벤트 핸들러, 그리고 접근성 속성들이 모두 올바르게 설정되었습니다.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
frontend/src/pages/MainPage/components/SearchBox/SearchBox.tsx (2)
14-18: 홈으로 리다이렉트 로직을 개선하세요.현재 로직은 단순 경로 비교만 하고 있어 query parameter나 hash가 있는 경우 불필요한 리다이렉트가 발생할 수 있습니다.
const redirectToHome = () => { - if (location.pathname !== '/') { + if (location.pathname !== '/' || location.search || location.hash) { - navigate('/'); + navigate('/', { replace: true }); } };
26-29: 객체 축약형을 사용하여 코드를 개선하세요.코딩 가이드라인에 따라 간결한 객체 표기법을 사용하는 것이 좋습니다.
trackEvent('Search Executed', { - inputValue: inputValue, + inputValue, page: currentPage, });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
frontend/src/components/common/Header/Header.tsx(1 hunks)frontend/src/components/common/SearchBox/SearchBox.tsx(0 hunks)frontend/src/components/common/SearchField/SearchField.tsx(1 hunks)frontend/src/pages/MainPage/components/SearchBox/SearchBox.tsx(1 hunks)
💤 Files with no reviewable changes (1)
- frontend/src/components/common/SearchBox/SearchBox.tsx
🧰 Additional context used
📓 Path-based instructions (2)
frontend/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (frontend/.cursorrules)
frontend/**/*.{ts,tsx}: Replace magic numbers with named constants for clarity.
Replace complex or nested ternary operators with if/else statements or IIFEs for readability.
Assign complex boolean conditions to named variables.
Use consistent return types for similar functions and hooks.
Avoid hidden side effects; functions should only perform actions implied by their signature (Single Responsibility Principle).
Use unique, descriptive names for custom wrappers and functions to avoid ambiguity.
Define constants near related logic or ensure names link them clearly.
Files:
frontend/src/components/common/Header/Header.tsxfrontend/src/pages/MainPage/components/SearchBox/SearchBox.tsxfrontend/src/components/common/SearchField/SearchField.tsx
frontend/**/*.tsx
📄 CodeRabbit Inference Engine (frontend/.cursorrules)
frontend/**/*.tsx: Abstract complex logic/interactions into dedicated components or higher-order 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.
Break down broad state management into smaller, focused hooks or contexts.
Use component composition instead of props drilling.
Files:
frontend/src/components/common/Header/Header.tsxfrontend/src/pages/MainPage/components/SearchBox/SearchBox.tsxfrontend/src/components/common/SearchField/SearchField.tsx
🧬 Code Graph Analysis (1)
frontend/src/pages/MainPage/components/SearchBox/SearchBox.tsx (2)
frontend/src/context/SearchContext.tsx (1)
useSearch(39-45)frontend/src/context/CategoryContext.tsx (1)
useCategory(11-18)
🔇 Additional comments (8)
frontend/src/components/common/Header/Header.tsx (1)
3-3: import 경로 변경이 적절합니다.SearchBox를 메인 페이지 전용 컴포넌트로 이동시킨 것은 공통 검색창 통일이라는 PR 목표에 부합합니다. 재사용 가능한 SearchField 컴포넌트를 도입하고 페이지별 특화된 SearchBox를 분리한 아키텍처 개선입니다.
frontend/src/pages/MainPage/components/SearchBox/SearchBox.tsx (2)
1-6: 의존성 import가 적절합니다.필요한 context, hook, 컴포넌트들을 명확하게 import하고 있으며, 새로운 SearchField 컴포넌트를 활용하는 구조가 좋습니다.
32-40: SearchField 사용이 적절합니다.새로운 SearchField 컴포넌트를 활용하여 UI와 비즈니스 로직을 적절히 분리했습니다. props 전달도 명확하고 한국어 placeholder와 aria-label 설정이 사용자 경험을 고려한 좋은 구현입니다.
frontend/src/components/common/SearchField/SearchField.tsx (5)
5-12: interface 정의가 명확합니다.props 타입 정의가 명확하고 선택적 props에 대한 기본값 설정도 적절합니다.
14-23: 기본값 설정과 ref 사용이 적절합니다.한국어 기본 placeholder와 aria-label 설정이 좋고, input blur 처리를 위한 ref 사용도 적절합니다.
25-29: form submit 핸들링이 올바릅니다.preventDefault() 호출과 조건부 blur 처리가 적절하게 구현되어 있습니다.
31-52: 접근성을 고려한 UI 구현이 훌륭합니다.form 요소 사용, aria-label 설정, 적절한 button type 지정 등 웹 접근성을 잘 고려한 구현입니다. focus 상태 관리도 사용자 경험을 향상시키는 좋은 기능입니다.
32-32: Transient Prop$isFocused검증 완료
- frontend/src/components/common/SearchField/SearchField.styles.ts: styled.form과 styled.button에서 제네릭
{ $isFocused: boolean }으로 선언·사용하여, DOM에 전달되지 않으면서 스타일링에 정상 작동함이 확인되었습니다.
추가 조치 불필요합니다.
#️⃣연관된 이슈
📝작업 내용
변경전 SearchBox
전역 컨텍스트, 이벤트 추적로직, 내부 state 등 너무 많은 기능이 들어가 있어 공통 컴포넌트 역할을 하지 못했습니다.
SearchField 로 분리
value, onChange, onSubmit, placeholder?, ariaLabel?, autoBlur?중점적으로 리뷰받고 싶은 부분(선택)
논의하고 싶은 부분(선택)
🫡 참고사항
Summary by CodeRabbit