fix: (QA/3) 홈으로 페이지 이동할 때 배너 이미지 로드 전에 텍스트만 뜨는 문제 해결 #385
Conversation
Walkthrough배너 카드에 이미지 로딩 상태( Changes
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
✨ Finishing Touches
🧪 Generate unit tests
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. Comment |
|
MATEBALL-STORYBOOK |
There was a problem hiding this comment.
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
📒 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); |
There was a problem hiding this comment.
이미지 로드 실패 시 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).
Deploying mateball-client with
|
| 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 |
#️⃣ Related Issue
Closes #384
💎 PR Point
홈으로 페이지 이동할 때, 상단 카드 배너 이미지가 로드 되지 않은 상태에서 이용 가이드 보러가기 텍스트가 먼저 로드 되어서 생기는 문제를 해결하고자 카드 배너에 로드 상태를 추가했습니다.
📸 Screenshot
Summary by CodeRabbit