Skip to content

Commit

Permalink
fix: Setting avatar src correctly resets error state
Browse files Browse the repository at this point in the history
  • Loading branch information
rkaraivanov committed Nov 18, 2021
1 parent 9b3d276 commit c26502b
Showing 1 changed file with 12 additions and 6 deletions.
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) {
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

0 comments on commit c26502b

Please sign in to comment.