Skip to content

fix(Avatar): fall back to initials when imageUrl is an empty string#3168

Merged
oliverlaz merged 1 commit intomasterfrom
fix/avatar-empty-image-url
May 5, 2026
Merged

fix(Avatar): fall back to initials when imageUrl is an empty string#3168
oliverlaz merged 1 commit intomasterfrom
fix/avatar-empty-image-url

Conversation

@oliverlaz
Copy link
Copy Markdown
Member

🎯 Goal

Prevent the Avatar component from rendering an <img> element with an empty src when imageUrl is an empty string. An empty src makes the browser attempt to load the current document URL as an image, which both wastes a request and triggers an unintended onError (which would then flip the avatar into the error fallback for the wrong reason).

🛠 Implementation details

showImage previously only checked that imageUrl was a string. An empty string passes typeof imageUrl === 'string', so the <img> was rendered with src="". Added a truthy check so an empty string now falls through to the initials/icon fallback path. Added a regression test for the empty-string case.

🎨 UI Changes

No visual changes for valid image URLs. When imageUrl="", the avatar now renders the username initials (or IconUser fallback) instead of a broken <img>.

An empty string passed `typeof imageUrl === 'string'`, so the component
rendered `<img src="">`, which makes the browser attempt to load the
current document URL as an image. Add a truthy check so empty strings
fall through to the initials/icon fallback path.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Size Change: +10 B (0%)

Total Size: 673 kB

📦 View Changed
Filename Size Change
dist/cjs/index.js 267 kB +5 B (0%)
dist/es/index.mjs 265 kB +5 B (0%)
ℹ️ View Unchanged
Filename Size
dist/cjs/audioProcessing.js 1.32 kB
dist/cjs/emojis.js 3.01 kB
dist/cjs/mp3-encoder.js 1.27 kB
dist/cjs/useNotificationApi.js 45.4 kB
dist/css/emoji-picker.css 178 B
dist/css/emoji-replacement.css 456 B
dist/css/index.css 39.6 kB
dist/es/audioProcessing.mjs 1.31 kB
dist/es/emojis.mjs 2.52 kB
dist/es/mp3-encoder.mjs 756 B
dist/es/useNotificationApi.mjs 45.2 kB

compressed-size-action

@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.50%. Comparing base (88c0ccc) to head (1f5187e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3168      +/-   ##
==========================================
- Coverage   83.55%   83.50%   -0.05%     
==========================================
  Files         434      434              
  Lines       12949    12949              
  Branches     4170     4170              
==========================================
- Hits        10819    10813       -6     
- Misses       2130     2136       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@oliverlaz oliverlaz merged commit 541eef8 into master May 5, 2026
9 checks passed
@oliverlaz oliverlaz deleted the fix/avatar-empty-image-url branch May 5, 2026 13:09
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