Skip to content

fix: (QA/3) 홈으로 페이지 이동할 때 배너 이미지 로드 전에 텍스트만 뜨는 문제 해결 #385

Merged
heesunee merged 2 commits intodevelopfrom
fix/#384/guide-message-flicker-home
Sep 8, 2025
Merged

fix: (QA/3) 홈으로 페이지 이동할 때 배너 이미지 로드 전에 텍스트만 뜨는 문제 해결 #385
heesunee merged 2 commits intodevelopfrom
fix/#384/guide-message-flicker-home

Conversation

@yeeeww
Copy link
Contributor

@yeeeww yeeeww commented Sep 8, 2025

#️⃣ Related Issue

Closes #384

💎 PR Point

홈으로 페이지 이동할 때, 상단 카드 배너 이미지가 로드 되지 않은 상태에서 이용 가이드 보러가기 텍스트가 먼저 로드 되어서 생기는 문제를 해결하고자 카드 배너에 로드 상태를 추가했습니다.

📸 Screenshot

image

Summary by CodeRabbit

  • Bug Fixes
    • 배너 이미지가 완전히 로드된 후에만 캡션 오버레이를 표시하여 초기 깜빡임과 레이아웃 이동을 줄였습니다.
  • Style
    • 캡션 레이아웃에 flex를 적용해 정렬성과 가독성을 개선했습니다.

@coderabbitai
Copy link

coderabbitai bot commented Sep 8, 2025

Walkthrough

배너 카드에 이미지 로딩 상태(imageLoaded)를 도입하고, 이미지의 onLoad 발생 시에만 캡션 오버레이를 렌더링하도록 조건부 렌더링과 클래스 조정을 적용했습니다. 공개 API(Props/기본 export)는 변경되지 않았습니다.

Changes

Cohort / File(s) Summary
BannerCard 로딩 상태 및 캡션 제어
src/shared/components/card/banner-card/banner-card.tsx
useStateimageLoaded 추가, 이미지 요소에 onLoad로 상태 갱신, 이미지에 min-h-[9.6rem] w-full 클래스 적용, imageLoaded가 true일 때만 캡션 오버레이 렌더링, 캡션 컨테이너에 flex/flex-col 추가. 공개 API 변화 없음.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User as User
    participant BC as BannerCard
    participant IMG as <img> (banner)

    User->>BC: BannerCard 렌더링
    BC->>IMG: 이미지 src 설정 (onLoad 등록)
    IMG-->>BC: onLoad 이벤트
    note right of BC #DDEBF7: imageLoaded = true로 설정
    BC->>BC: 조건부 렌더링 평가
    alt imageLoaded == true
        BC-->>User: 캡션 오버레이 렌더링
    else
        BC-->>User: 캡션 숨김
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
홈 이동 시 ‘이용 가이드 보기’ 문구 비표시 문제 해결 (#384) 해당 이슈는 특정 문구 노출 제어와 관련되며, PR은 이미지 로드 기반 캡션 렌더링만 변경함 — 직접 연결 여부 불명확.

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
배너 이미지 onLoad 기반 imageLoaded 상태 추가 및 캡션 조건부 렌더링 (src/shared/components/card/banner-card/banner-card.tsx) 링크된 이슈(#384)는 홈 이동 시 특정 안내 문구 노출과 관련된 문제라, 이미지 로드/캡션 렌더링 변경은 명시된 목표와 직접적인 관련이 아님.

Possibly related PRs

Suggested labels

fix

Suggested reviewers

  • Dubabbi
  • heesunee
  • bongtta

Poem

"이미지 깜빡, 토끼는 대기해요 🐇
픽셀 숨 쉬면 캡션이 춤춰요 ✨
로드 신호에 살랑 뛰어올라
깔끔히 덮어주는 작은 오버레이
오늘도 배너는 제자리를 지켜요."


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 01433b2 and e4ce7df.

📒 Files selected for processing (1)
  • src/shared/components/card/banner-card/banner-card.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/shared/components/card/banner-card/banner-card.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: chromatic
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/#384/guide-message-flicker-home

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

github-actions bot commented Sep 8, 2025

MATEBALL-STORYBOOK
⚾ Storybook 배포가 완료되었습니다!

Copy link

@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

🧹 Nitpick comments (2)
src/shared/components/card/banner-card/banner-card.tsx (2)

17-17: 초기 페인트 가속(선택): eager/decoding/fetchpriority로 LCP 개선

배너가 홈 상단 LCP 후보라면 즉시 로딩을 권장합니다.

-      <img
+      <img
         src={BannerImg}
         alt="홈배너"
         className="w-full"
+        loading="eager"
+        decoding="async"
+        fetchpriority="high"
         onLoad={() => setOverlayReady(true)}
         onError={() => setOverlayReady(true)}
       />

17-23: A11y(선택): 캡션 숨김 상태에서도 버튼 접근성 이름 유지

overlay가 뜨기 전에는 텍스트가 없어 스크린리더 이름이 불안정합니다. 버튼에 aria-label을 추가해 일관된 이름을 보장해 주세요.

예시(선택, 변경 대상: Line 16):

<button
  type="button"
  className={cn('relative cursor-pointer text-left')}
  onClick={onClick}
  aria-label={text}
/>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f7ca6a0 and 01433b2.

📒 Files selected for processing (1)
  • src/shared/components/card/banner-card/banner-card.tsx (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/shared/components/card/banner-card/banner-card.tsx (1)
src/shared/libs/cn.ts (1)
  • cn (4-6)
🔇 Additional comments (1)
src/shared/components/card/banner-card/banner-card.tsx (1)

2-2: useState 도입 적절 — 의도에 부합합니다

이미지 로딩 완료 시점까지 캡션을 게이트하려는 목적과 맞습니다.

}

const BannerCard = ({ text, subText, onClick }: CardBannerProps) => {
const [imageLoaded, setImageLoaded] = useState(false);
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

이미지 로드 실패 시 CTA가 영구히 숨겨질 수 있음 — onError/폴백 필요

현재는 onLoad에만 의존해 overlay가 표시됩니다. 네트워크 오류/404 등으로 이미지가 실패하면 안내 텍스트(CTA)가 영원히 노출되지 않습니다. 또한 subText가 없을 때도 빈 p가 렌더링됩니다. 아래처럼 실패 시에도 overlay를 열고, subText는 존재할 때만 렌더링하도록 보완해 주세요.

-  const [imageLoaded, setImageLoaded] = useState(false);
+  const [overlayReady, setOverlayReady] = useState(false);
@@
-      <img src={BannerImg} alt="홈배너" className="w-full" onLoad={() => setImageLoaded(true)} />
-      {imageLoaded && (
+      <img
+        src={BannerImg}
+        alt="홈배너"
+        className="w-full"
+        onLoad={() => setOverlayReady(true)}
+        onError={() => setOverlayReady(true)}
+      />
+      {overlayReady && (
         <div className="absolute inset-0 flex flex-col justify-center gap-[0.4rem] py-[2.2rem] pl-[2.4rem]">
-          <p className="cap_14_m text-gray-800">{subText}</p>
+          {subText && <p className="cap_14_m text-gray-800">{subText}</p>}
           <p className="subhead_18_sb text-gray-black">{text}</p>
         </div>
       )}

Also applies to: 17-23

🤖 Prompt for AI Agents
In src/shared/components/card/banner-card/banner-card.tsx around lines 13 (and
also lines 17-23), the component only sets imageLoaded via onLoad so a failed
image prevents the overlay/CTA from ever showing and an empty <p> renders when
subText is missing; add an onError handler on the img that also calls
setImageLoaded(true) (or set a separate imageError flag and derive "showOverlay"
from imageLoaded || imageError) so the overlay appears on load failure, and
change the JSX to render the subText <p> only when subText is truthy (i.e.,
conditionally render the element to avoid empty tags).

@cloudflare-workers-and-pages
Copy link

Deploying mateball-client with  Cloudflare Pages  Cloudflare Pages

Latest commit: e4ce7df
Status: ✅  Deploy successful!
Preview URL: https://be6450bc.mateball-client.pages.dev
Branch Preview URL: https://fix--384-guide-message-flick.mateball-client.pages.dev

View logs

@heesunee heesunee added the fix label Sep 8, 2025
@heesunee heesunee merged commit 88165f8 into develop Sep 8, 2025
7 checks passed
@heesunee heesunee deleted the fix/#384/guide-message-flicker-home branch September 8, 2025 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: 다른 페이지에서 홈으로 이동 시 이용 가이드 보기 문구 뜨는 현상 해결합니다.

2 participants