Skip to content

fix(ui): replace DOM-mutating image fallbacks with ImageWithFallback - #239

Merged
Atharva0506 merged 1 commit into
StabilityNexus:mainfrom
Atharva0506:fix/image-fallback-component
Oct 9, 2026
Merged

Atharva0506 merged 1 commit into
StabilityNexus:mainfrom
Atharva0506:fix/image-fallback-component

Conversation

@Atharva0506

@Atharva0506 Atharva0506 commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Addressed Issues:

Part of #122

The remaining occurrences are in ReceivedInvoice.jsx, SentInvoice.jsx and BatchPayment.jsx, which open PRs (#227, #209, #207, #234) are editing. They'll move to this component in a follow-up once those merge, so this PR doesn't close the issue.

Screenshots/Recordings:

NA added fallback if image fails to load

Additional Notes:

  • New ImageWithFallback (src/components/ImageWithFallback.jsx) keeps the failure in React state instead of writing to the DOM: it tries src, then fallbackSrc, then renders the fallback node (or nothing). Each source is tried once, so a broken fallback image can no longer loop on onError, and the state resets when src changes. Other props pass through to <img>.
  • Migrated: CountryPicker (2), InvoicePreview (logo + payment token), TokenCrousel, TokenPicker (via Avatar).
  • Avatar now takes fallbackSrc instead of onError; if both the token image and the generic icon fail, it shows the token's initials. TokenPicker is its only consumer.
  • No component test: Jest runs in a node environment without a JSX transform, so testing a component needs babel, jsdom and testing-library. Happy to add that setup in its own PR.
  • npm run lint, npm run test and npm run build pass.

AI Usage Disclosure:

Check one of the checkboxes below:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

I have used the following AI models and tools: Claude Code (Claude Opus 5.5)

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • I have filled this PR template completely and carefully, and I understand that my PR may be closed without review otherwise.

The onError handlers in CountryPicker, InvoicePreview, TokenCrousel and
TokenPicker hid images or swapped their src by writing to the DOM
directly. React doesn't know about those writes, and a broken fallback
image re-fires onError forever.

ImageWithFallback keeps the failure in state instead: it tries src, then
fallbackSrc, then renders a fallback node. Each source is tried once,
and the state resets when src changes. Avatar now uses it, so a token
whose image and generic icon both fail shows its initials.

Part of StabilityNexus#122
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 36 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: StabilityNexus/Chainvoice/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 71168a53-ad3b-41ae-abac-baec510cd7d4
📥 Commits

Reviewing files that changed from the base of the PR and between e4525cd and cc9dfe1.

📒 Files selected for processing (6)
  • frontend/src/components/CountryPicker.jsx
  • frontend/src/components/ImageWithFallback.jsx
  • frontend/src/components/InvoicePreview.jsx
  • frontend/src/components/TokenCrousel.jsx
  • frontend/src/components/TokenPicker.jsx
  • frontend/src/components/ui/avatar.jsx
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🔍 PR Preview

Status 🗑️ Removed — this pull request is closed

github-actions Bot added a commit that referenced this pull request Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

✅ Build successful!

Build Size Metrics
Metrics not found

Workflow run · commit cc9dfe1

@Atharva0506
Atharva0506 marked this pull request as ready for review October 6, 2026 09:17
@Atharva0506
Atharva0506 merged commit f1730ba into StabilityNexus:main Oct 9, 2026
7 checks passed
github-actions Bot added a commit that referenced this pull request Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant