kirbydesign / designsystem

Kirby Design System
https://cookbook.kirby.design
MIT License
82 stars 22 forks source link

[Enhancement] Kirby Avatar should handle broken links #3419

Open jvh2 opened 3 months ago

jvh2 commented 3 months ago

Describe the enhancement

Kirby avatar component should handle broken link for attribute [imageSrc] with an error handle event

Describe the solution you'd like

Kirby avatar component is expanded with a onerror event handler to handle broken links in [imageSrc]. Therefor we would like the kirby avatar component to be expanded with an error event handler.

Have you considered any alternatives?

Are there any additional context?


Checklist:

The following tasks should be carried out in sequence in order to follow the process of contributing correctly.

Refinement

Implementation

The contributor who wants to implement this issue should:

Review

Once the issue has been implemented and is ready for review:

stale[bot] commented 1 month ago

This issue has been automatically marked as stale because of no recent activity. It will be closed in 10 weeks if no further activity occurs. Thank you for your contributions.

Fuzzy3 commented 4 days ago

Tech Refinement As suggested the kirby-avatar should be extended with an onerror handler for the img within the avatar.

The native error handling is described here

As written in the error handling section of img elements in the mdn-site, there are multiple causes that may trigger the onerror. In that regard we intend to emit the full ErrorEvent since the consumer of this may need different information based on the cause of the error.

The event will be distributed through an EventEmitter<ErrorEvent> attribute: imgError which may be set on the kirby-avatar component to receive a callback when the img src returns an invalid image.