Skip to content

Handle user avatar error#3735

Merged
huchenlei merged 7 commits intomainfrom
user-image-error
May 7, 2025
Merged

Handle user avatar error#3735
huchenlei merged 7 commits intomainfrom
user-image-error

Conversation

@christian-byrne
Copy link
Contributor

@christian-byrne christian-byrne commented May 2, 2025

When Avatar component emits error, use icon as fallback.

Prevents this scenario:

Workspace 1_008

Additionally, adds translation for aria label.

Copy link
Contributor

@huchenlei huchenlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are various other places where we just Avatar, Ideally we wrap it in a new component so the fallback logic can be reused.

@christian-byrne
Copy link
Contributor Author

There are various other places where we just Avatar, Ideally we wrap it in a new component so the fallback logic can be reused.

Good point.

@christian-byrne
Copy link
Contributor Author

Changes:

  • Create dedicated component UserAvatar in common components folder
  • Use UserAvatar in two places Avatar was being used
  • Add basic component test

@christian-byrne christian-byrne requested a review from huchenlei May 5, 2025 20:16
Copy link
Contributor

@huchenlei huchenlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can

<Avatar
class="mb-3"
:image="user?.photoURL ?? undefined"
:icon="user?.photoURL ? undefined : 'pi pi-user !text-2xl'"
shape="circle"
size="large"
aria-label="User Avatar"
/>
also be replaced?

@christian-byrne
Copy link
Contributor Author

Changes:

  • Allow/handle using fallback when null passed for photoUrl prop, for easier use with firebase store currentUser + add unit test to verify
  • Use UserAvatar component in CurrentUserPopover. Maintain icon class styling with pt syntax:
              :pt:icon:class="{
                '!text-2xl': !user?.photoURL
              }"

@christian-byrne christian-byrne requested a review from huchenlei May 6, 2025 23:45
@huchenlei huchenlei merged commit bbbf140 into main May 7, 2025
10 checks passed
@huchenlei huchenlei deleted the user-image-error branch May 7, 2025 02:04
christian-byrne added a commit that referenced this pull request May 9, 2025
Co-authored-by: github-actions <github-actions@github.com>
christian-byrne added a commit that referenced this pull request May 20, 2025
Co-authored-by: github-actions <github-actions@github.com>
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.

2 participants