Skip to content

feat: fixed bottom bar를 <body>에 가깝게 위치함#335

Open
KSJ27 wants to merge 4 commits intomainfrom
refactor/fbb
Open

feat: fixed bottom bar를 <body>에 가깝게 위치함#335
KSJ27 wants to merge 4 commits intomainfrom
refactor/fbb

Conversation

@KSJ27
Copy link
Copy Markdown
Contributor

@KSJ27 KSJ27 commented Jan 26, 2026

작업 내용

기존에는

  • fixed bottom bar 컴포넌트가 화면에서 가장 앞을 차지하지만, DOM에선 특정 컴포넌트 내부에 위치했습니다.
  • 실제로 하는 일과 DOM 상 위치가 불일치하기 때문에 동작을 추적하기 어려운 문제가 있었습니다.

개선

<body>의 자식 컨테이너에 fbb가 위치하도록 했습니다.

비교

Before

스크린샷 2026-01-26 오후 5 25 46

After

스크린샷 2026-01-26 오후 5 24 33

Summary by CodeRabbit

릴리스 노트

  • New Features

    • 고정 하단 바가 페이지 외부에 안정적으로 렌더링되어 레이아웃 충돌이 줄어듭니다.
  • 테스트

    • 고정 하단 바에 대한 포괄적인 테스트 스위트 추가로 렌더링·레이아웃 동작을 검증합니다.
  • 리팩터

    • 하단 바 렌더링 흐름과 레이아웃 처리 개선으로 안정성 및 유지보수성이 향상되었습니다.
  • 스토리북

    • 스토리북에서 하단 바가 정상적으로 표시되도록 데코레이터 보완되었습니다.

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

@KSJ27 KSJ27 self-assigned this Jan 26, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 26, 2026

Walkthrough

FixedBottomBar를 React portal로 렌더링하도록 변경하고, 앱 레이아웃에 portal 컨테이너를 주입하며 관련 스토리북 데코레이터와 테스트를 추가했습니다.

Changes

Cohort / File(s) Summary
FixedBottomBar 컴포넌트
src/components/layout/FixedBottomBar/index.tsx
컴포넌트를 portal로 렌더링하도록 변경; FIXED_BOTTOM_BAR_CONTAINER_ID 상수 export 추가; 태그 및 ref 타입 조정; portal 대상 조건부 렌더링 및 spacer 유지
FixedBottomBar 테스트
src/components/layout/FixedBottomBar/index.test.tsx
새 테스트 추가: portal 컨테이너 생성/정리, ResizeObserver 및 getBoundingClientRect 모킹, 콘텐츠 렌더링 및 spacer 높이 검증
Storybook 데코레이터
src/components/layout/FixedBottomBar/index.stories.tsx
FIXED_BOTTOM_BAR_CONTAINER_ID import 및 story용 데코레이터 추가(포탈 컨테이너 보장)
앱 레이아웃 통합
src/app/layout.tsx
FIXED_BOTTOM_BAR_CONTAINER_ID import 및 ModalControllerProvider 직전에 portal 컨테이너 div 삽입

Sequence Diagram(s)

sequenceDiagram
    participant App as 앱 레이아웃 (layout.tsx)
    participant Doc as document/body
    participant Bar as FixedBottomBar 컴포넌트
    App->>Doc: portal 컨테이너 div(id=FIXED_BOTTOM_BAR_CONTAINER_ID) 주입
    Bar->>Doc: portalTarget = getElementById(FIXED_BOTTOM_BAR_CONTAINER_ID)
    Bar->>Doc: createPortal(바 콘텐츠) -> portalTarget
    Bar->>Bar: 로컬 spacer 높이 계산 및 동기화
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • Yun-Jinwoo
  • junyeongh

Poem

🐰 포탈로 살짝 뛰어들어,
바닥에 자리를 만들었네,
스페이서로 균형 잡고,
스토리와 테스트로 다졌네,
햇살 속에 반짝이는 작은 변화.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed 제목이 PR의 주요 변경사항을 명확하게 반영하고 있습니다. fixed bottom bar를 body에 더 가깝게 위치시키는 것이 핵심 변경사항이며, 제목은 이를 간결하고 구체적으로 표현합니다.
Description check ✅ Passed PR 설명이 템플릿 요구사항을 충실히 만족합니다. 작업 내용이 상세하게 작성되었고, 기존 상태와 개선사항을 명확히 구분하여 설명했으며, 시각적 비교를 위한 스크린샷도 포함되어 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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

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

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 26, 2026

🧷 배포 미리보기: https://run-ro1ry3d5x-shionparks-projects.vercel.app
최종 업데이트: 2026년 01월 29일 10시 18분

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: 2

🤖 Fix all issues with AI agents
In `@src/components/layout/FixedBottomBar/index.test.tsx`:
- Around line 7-37: The test's global ResizeObserver mock is not restored,
risking leakage to other tests; in beforeEach save the original
global.ResizeObserver (e.g., const originalResizeObserver =
global.ResizeObserver) before mocking it in the beforeEach that sets up
ResizeObserver, and in afterEach restore it (assign originalResizeObserver back
to global.ResizeObserver) alongside the existing jest.restoreAllMocks() and DOM
cleanup for container (refer to the existing beforeEach/afterEach,
FIXED_BOTTOM_BAR_CONTAINER_ID, and the ResizeObserver mock to locate where to
add the save/restore).

In `@src/components/layout/FixedBottomBar/index.tsx`:
- Around line 45-59: The portal currently calls createPortal(...,
document.getElementById(FIXED_BOTTOM_BAR_CONTAINER_ID)!) which will throw if the
container is missing; update the rendering to guard against a null container by
retrieving the element with
document.getElementById(FIXED_BOTTOM_BAR_CONTAINER_ID) into a variable and only
call createPortal (or render the portal block) when that element is non-null —
keep using FIXED_BOTTOM_BAR_CONTAINER_ID, createPortal, barRef and children but
ensure a null-check prevents the runtime crash in environments where the
container may not exist.

@KSJ27 KSJ27 added the ready-for-review 리뷰 받을 준비되었습니다! label Jan 29, 2026
Copy link
Copy Markdown
Contributor

@shionpark shionpark left a comment

Choose a reason for hiding this comment

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

“실제로 하는 역할과 DOM 상 위치가 불일치해 동작을 추적하기 어렵다”고 언급하신 부분에서
어떤 상황에서 문제가 발생하는지 궁금해서 찾아봤습니다.

FBB처럼 화면상으로는 전역 UI로 동작하지만 DOM 상에서는 특정 컴포넌트 내부에 위치한 경우,
레이아웃(overflow, stacking context), 이벤트 전파, 지역 스타일 상속 등의 이슈에서
원인을 구조만 보고 파악하기 어려워질 수 있다고 하네요. (참고 자료 첨부)

createPortal을 통해 FBB를 전역 레이어로 분리함으로써,
레이아웃·이벤트·스타일 동작을 DOM 구조 기준으로 추론할 수 있게 된 점이 좋아보입니다! 👍

비슷한 맥락에서, 전역 레이어 성격을 가진 모달 UI 역시
createPortal 기반으로 리팩토링을 고려해볼 수 있을 것 같네요!

참고 자료:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review 리뷰 받을 준비되었습니다!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants