Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Setting avatar src correctly resets error state #140

Merged
merged 2 commits into from
Nov 22, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/components/avatar/avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,18 @@ export default class IgcAvatarComponent extends SizableMixin(LitElement) {
/** @private */
public static styles = [styles];

public set src(val: string) {
rkaraivanov marked this conversation as resolved.
Show resolved Hide resolved
const oldVal = this._src;
this._src = val;
this.hasError = false;
this.requestUpdate('src', oldVal);
}

/** The image source to use. */
@property()
public src!: string;
public get src() {
return this._src;
}

@state()
private hasError = false;
Expand All @@ -44,6 +53,8 @@ export default class IgcAvatarComponent extends SizableMixin(LitElement) {
@property({ reflect: true })
public shape: 'circle' | 'rounded' | 'square' = 'square';

private _src!: string;

private get classes() {
const { size, shape } = this;

Expand Down Expand Up @@ -89,11 +100,6 @@ export default class IgcAvatarComponent extends SizableMixin(LitElement) {
}
}

// export const avatarDefinition: IgcComponentDefinition = {
// tag: 'igc-avatar',
// component: IgcAvatarComponent,
// };

declare global {
interface HTMLElementTagNameMap {
'igc-avatar': IgcAvatarComponent;
Expand Down