fix: replace broken image fallback with proper error state in ZoomableImage (#1184)Fix/UI flicker missing images#1239
Conversation
WalkthroughModified Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 Tip You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.Change the |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
frontend/src/components/Media/ZoomableImage.tsx (1)
424-453: Consider preventing zoom/pan interactions on the error UI.The error fallback is rendered inside
TransformComponent, which means users can still zoom and pan the error message. This may be unintended UX behavior.Consider either:
- Moving the error UI outside
TransformWrapperentirely, or- Disabling interactions when in error state by conditionally setting
panning.disabledandwheel.disabledbased onhasError.Additionally, for accessibility, consider adding
role="alert"to announce the error state to screen readers.♻️ Suggested accessibility improvement
{hasError ? ( <div + role="alert" className="flex flex-col items-center justify-center gap-4 rounded-lg bg-gray-900 p-12 text-center" style={{ minWidth: '320px', minHeight: '220px' }} >🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@frontend/src/components/Media/ZoomableImage.tsx` around lines 424 - 453, The error UI is rendered inside TransformComponent which allows zoom/pan even when hasError is true; either move the error fallback out of TransformWrapper/TransformComponent or disable interactions when hasError by setting TransformWrapper/TransformComponent props like panning.disabled and wheel.disabled based on hasError, and add role="alert" to the error container for screen reader announcement; update the conditional that renders the error UI around hasError and adjust TransformWrapper/TransformComponent usage accordingly (refer to hasError, TransformWrapper, TransformComponent, panning.disabled, wheel.disabled, and add role="alert").
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@frontend/src/components/Media/ZoomableImage.tsx`:
- Around line 424-453: The error UI is rendered inside TransformComponent which
allows zoom/pan even when hasError is true; either move the error fallback out
of TransformWrapper/TransformComponent or disable interactions when hasError by
setting TransformWrapper/TransformComponent props like panning.disabled and
wheel.disabled based on hasError, and add role="alert" to the error container
for screen reader announcement; update the conditional that renders the error UI
around hasError and adjust TransformWrapper/TransformComponent usage accordingly
(refer to hasError, TransformWrapper, TransformComponent, panning.disabled,
wheel.disabled, and add role="alert").
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 9eca17a5-de1f-4f4f-a0d5-9f8b40ac571e
📒 Files selected for processing (1)
frontend/src/components/Media/ZoomableImage.tsx
|
Hey thanks for contributing but currently we are closing all prs that are linked to unreviewed issues please wait for mentors to discuss the issue mention your issue with some idea in the discord channel and wait for them to assign it to you then go ahead with the pr! |
Fixes #1184
Problem
The
onErrorhandler inZoomableImage.tsxwas settingimg.src = '/placeholder.svg'which triggered another errorif the SVG was missing, causing an infinite flicker loop.
Solution
hasErrorstate to track image load failuresuseEffectto reset error state when navigating to new image"Image could not be loaded" message and the file path
onErrorsets state once and Reactremoves the broken
<img>elementTesting
Summary by CodeRabbit