Skip to content

Commit

Permalink
Add fix to reshow card icon if previously it failed to load
Browse files Browse the repository at this point in the history
  • Loading branch information
sponglord committed Nov 14, 2024
1 parent 30b750d commit e6478e7
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ export default function BrandIcon({ brand, brandsConfiguration = {} }: BrandIcon
const getImage = useImage();
const imageName = brand === 'card' ? 'nocard' : brand;
const imageUrl = brandsConfiguration[brand]?.icon ?? getCardImageUrl(imageName, getImage);

const handleError = e => {
e.target.style.cssText = 'display: none';
};

const handleLoad = e => {
e.target.style.cssText = 'display: block';
};

return (
<img
className="adyen-checkout-card-input__icon adyen-checkout__card__cardNumber__brandIcon"
onLoad={handleLoad}
onError={handleError}
alt={getFullBrandName(brand)}
src={imageUrl}
Expand Down

0 comments on commit e6478e7

Please sign in to comment.