Skip to content

feat: 가상 스크롤 구현 및 반응형 추가#200

Merged
hyeeuncho merged 2 commits intodevelopfrom
feat/#197/virtual-scroll
Jun 30, 2025
Merged

feat: 가상 스크롤 구현 및 반응형 추가#200
hyeeuncho merged 2 commits intodevelopfrom
feat/#197/virtual-scroll

Conversation

@hyeeuncho
Copy link
Copy Markdown
Member

@hyeeuncho hyeeuncho commented Jun 27, 2025

image

Summary by CodeRabbit

  • 신규 기능

    • 이벤트 목록에 가상 스크롤(virtualized list) 기능이 도입되어 많은 이벤트가 있을 때도 성능이 향상되었습니다.
  • 개선 사항

    • 모바일과 데스크톱 화면 크기에 따라 이벤트 카드 레이아웃과 높이가 자동으로 조정됩니다.
    • 모든 이벤트가 날짜 필터 없이 표시됩니다.
    • 무한 스크롤이 더욱 부드럽게 동작합니다.
    • 스크롤 컨테이너에 접근성 속성(role, aria-label, tabIndex)이 추가되었습니다.
  • 버그 수정

    • 빈 목록 상태가 더 정확하게 표시됩니다.

@hyeeuncho hyeeuncho linked an issue Jun 27, 2025 that may be closed by this pull request
3 tasks
@hyeeuncho hyeeuncho self-assigned this Jun 27, 2025
@hyeeuncho hyeeuncho added the 🔧 Feature 기능 구현 label Jun 27, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jun 27, 2025

"""

Walkthrough

이 변경 사항은 EventList 컴포넌트에 가상화 리스트를 도입하여, 페이지네이션된 이벤트 데이터를 평탄화하고 2개씩 행 단위로 렌더링하며, 무한 스크롤 트리거와 빈 상태 확인 로직을 개선합니다. 또한, 이전의 교차 관찰자 로직을 제거하고 접근성 속성을 추가했습니다.

Changes

파일/경로 변경 요약
src/features/event/ui/EventList.tsx useVirtualizer 기반 가상화 리스트 구현, 2개 이벤트 행 단위 렌더링, 무한 스크롤 트리거 개선, 날짜 필터 제거, 접근성 속성 추가, 교차 관찰자 로직 삭제

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EventList
    participant useVirtualizer
    participant DataSource

    User->>EventList: 스크롤 또는 진입
    EventList->>useVirtualizer: 뷰포트 및 행 정보 전달
    useVirtualizer->>EventList: 가시적 행 목록 반환
    EventList->>DataSource: 다음 이벤트 페이지 요청 (필요 시)
    DataSource-->>EventList: 새 이벤트 데이터 반환
    EventList->>useVirtualizer: 데이터 및 행 정보 갱신
    EventList->>User: 가상화된 이벤트 행 렌더링
Loading

Poem

🐇
두 줄로 춤추는 이벤트 행,
가상화 바람에 가볍게 스크롤!
무한 목록도 문제없어요,
토끼는 깡충깡충 뛰어가네~
🥕✨
"""

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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

Documentation and Community

  • 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.

@github-actions
Copy link
Copy Markdown

Copy link
Copy Markdown

@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: 3

🧹 Nitpick comments (2)
src/features/event/ui/EventList.tsx (2)

62-67: 코드 개선: 불필요한 non-null assertion 제거

이미 null 체크를 했으므로 non-null assertion 연산자(!)가 불필요합니다.

 if (!firstRowRef.current) return;
 requestAnimationFrame(() => {
-  const measuredHeight = firstRowRef.current!.offsetHeight;
+  const measuredHeight = firstRowRef.current?.offsetHeight;
-  if (measuredHeight && measuredHeight !== rowHeight) {
+  if (measuredHeight && firstRowRef.current && measuredHeight !== rowHeight) {
     setRowHeight(measuredHeight);
   }
 });

27-154: 가상 스크롤 구현 잘 되었습니다!

가상화를 통한 성능 최적화가 잘 구현되었습니다. 추가로 고려해볼 사항:

  1. 키보드 네비게이션 지원 추가
  2. 초기 로딩 상태 처리
  3. 가상화 실패 시 에러 바운더리 적용
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dfcb2d1 and bf3165a.

📒 Files selected for processing (1)
  • src/features/event/ui/EventList.tsx (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: storybook

@github-actions
Copy link
Copy Markdown

Copy link
Copy Markdown

@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: 1

♻️ Duplicate comments (3)
src/features/event/ui/EventList.tsx (3)

52-56: resize 이벤트에 디바운스 적용 필요

윈도우 크기 조정 시 resize 이벤트가 빈번하게 발생하여 불필요한 리렌더링이 발생할 수 있습니다.


101-107: 접근성 및 반응형 개선 필요

스크롤 가능한 컨테이너에 접근성 속성이 없고, 고정 높이가 모든 화면에 적합하지 않을 수 있습니다.


129-129: 모바일 반응형 레이아웃 개선 필요

모바일에서 2열 그리드는 카드가 너무 작게 표시될 수 있습니다.

🧹 Nitpick comments (2)
src/features/event/ui/EventList.tsx (2)

112-151: 가상화 렌더링 로직 개선

현재 구현은 올바르지만, 성능 최적화와 접근성을 위해 몇 가지 개선이 가능합니다.

  1. 가상 행에 적절한 aria-rowindex 속성 추가
  2. 키보드 내비게이션을 위한 role="row" 추가
 <div
   key={virtualRow.index}
   ref={virtualRow.index === 0 ? firstRowRef : null}
+  role="row"
+  aria-rowindex={virtualRow.index + 1}
   style={{
     position: 'absolute',
     top: 0,
     left: 0,
     width: '100%',
     transform: `translateY(${virtualRow.start}px)`,
   }}
   className="grid grid-cols-1 md:grid-cols-2 gap-4"
 >

116-116: 배열 필터링 최적화

filter(Boolean)은 올바르지만, 더 명시적인 타입 가드를 사용하는 것이 좋습니다.

-const items = [flatEvents[firstIndex], flatEvents[secondIndex]].filter(Boolean);
+const items = [flatEvents[firstIndex], flatEvents[secondIndex]].filter((item): item is EventListProps => item !== undefined);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bf3165a and 4863657.

📒 Files selected for processing (1)
  • src/features/event/ui/EventList.tsx (4 hunks)
🔇 Additional comments (2)
src/features/event/ui/EventList.tsx (2)

71-78: 가상화 설정이 올바르게 구현됨

useVirtualizer 설정이 적절하며, 동적 높이 측정과 적절한 overscan 값을 사용하고 있습니다.


80-88: 무한 스크롤 로직의 기준이 되는 rowCountuseVirtualizer 초기화 부분을 함께 확인해 주세요:

#!/bin/bash
# 1. rowCount 변수 정의 위치 및 값 확인
rg -n "rowCount" -A5 -B5 -g '*.tsx'
# 2. useVirtualizer 초기화 코드 확인
rg -n "useVirtualizer" -A5 -B5 -g '*.tsx'

Comment on lines +61 to +69
useEffect(() => {
if (!firstRowRef.current) return;
requestAnimationFrame(() => {
const measuredHeight = firstRowRef.current!.offsetHeight;
if (measuredHeight && measuredHeight !== rowHeight) {
setRowHeight(measuredHeight);
}
});
}, [flatEvents, windowWidth]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

높이 측정 로직에서 잠재적 경쟁 조건 개선 필요

requestAnimationFrame 내에서 ref가 여전히 존재하는지 확인하지 않아 컴포넌트가 언마운트된 후에도 상태 업데이트가 발생할 수 있습니다.

 useEffect(() => {
   if (!firstRowRef.current) return;
   requestAnimationFrame(() => {
+    if (!firstRowRef.current) return;
     const measuredHeight = firstRowRef.current!.offsetHeight;
     if (measuredHeight && measuredHeight !== rowHeight) {
       setRowHeight(measuredHeight);
     }
   });
 }, [flatEvents, windowWidth]);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useEffect(() => {
if (!firstRowRef.current) return;
requestAnimationFrame(() => {
const measuredHeight = firstRowRef.current!.offsetHeight;
if (measuredHeight && measuredHeight !== rowHeight) {
setRowHeight(measuredHeight);
}
});
}, [flatEvents, windowWidth]);
useEffect(() => {
if (!firstRowRef.current) return;
requestAnimationFrame(() => {
if (!firstRowRef.current) return;
const measuredHeight = firstRowRef.current!.offsetHeight;
if (measuredHeight && measuredHeight !== rowHeight) {
setRowHeight(measuredHeight);
}
});
}, [flatEvents, windowWidth]);
🤖 Prompt for AI Agents
In src/features/event/ui/EventList.tsx around lines 61 to 69, the useEffect hook
uses requestAnimationFrame to measure height but does not verify if
firstRowRef.current still exists inside the callback, risking state updates
after unmount. To fix this, add a check inside the requestAnimationFrame
callback to confirm firstRowRef.current is still defined before accessing
offsetHeight and calling setRowHeight.

@hyeeuncho hyeeuncho requested a review from Yejiin21 June 27, 2025 08:56
Copy link
Copy Markdown
Contributor

@Yejiin21 Yejiin21 left a comment

Choose a reason for hiding this comment

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

수고하셨습니다

@hyeeuncho hyeeuncho merged commit df4184d into develop Jun 30, 2025
2 checks passed
@hyeeuncho hyeeuncho deleted the feat/#197/virtual-scroll branch June 30, 2025 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔧 Feature 기능 구현

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] 전체 이벤트 조회 페이지 가상 스크롤 구현

2 participants