Repository navigation
fix(Avatar): AvatarGroupOverflow grows to a pill for long +N counts (#4167) - #4196
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Quick Self-Review (refactor/update checklist)
Design notes
|
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsAvatarGroup · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: 1 accessibility violation(s) found — 1 serious. AvatarGroup - 1 issue(s)
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
| // horizontally into a stadium/pill for wide content (`+4912`) without | ||
| // clipping. The min width subtracts the inline padding (applied on both | ||
| // sides via `boxSizing: content-box`) so the circle diameter equals `s`. | ||
| minWidth: Math.max(0, s - OVERFLOW_PADDING_INLINE * 2), |
There was a problem hiding this comment.
Use tokens not hardcoded values
There was a problem hiding this comment.
Removed. The OVERFLOW_PADDING_INLINE = 8 constant (a raw mirror of the --spacing-2 token) is gone entirely. paddingInline now reads spacingVars['--spacing-2'] directly, and thanks to the border-box switch there's no JS-side arithmetic that needed the token's numeric value.
| // the box stays a perfect circle for short counts (`+5`) and grows | ||
| // horizontally into a stadium/pill for wide content (`+4912`) without | ||
| // clipping. The min width subtracts the inline padding (applied on both | ||
| // sides via `boxSizing: content-box`) so the circle diameter equals `s`. |
There was a problem hiding this comment.
Sounds like we can clean this up by using border box so simplify this
There was a problem hiding this comment.
Done — switched to boxSizing: 'border-box'. With border-box the inline padding lives inside the box, so minWidth can be set to the size directly (grown by the 2px border to match the sibling avatars' rendered size). Short counts stay a perfect circle at the avatar size; longer content pushes past the min width and grows into a pill. No more subtraction arithmetic.
The overflow indicator was a fixed-size circle, so wide counts (e.g. +4912) clipped/crowded the edges. Switch to border-box and enforce a minimum width equal to the avatar size: short counts stay a circle, and the inline padding (inside the box) lets longer counts grow into a stadium/pill so the number always fits. Closes #4167
e89a93d to
7a28722
Compare
Review feedback addressed (force-pushed)Both inline comments resolve together via the border-box switch:
Sizing now reads: Re-ran gates: Accessibility finding — pre-existing, not introduced by this PRThe reported This color pairing is part of the component's existing styling and is unchanged by this PR — the same Fixing the contrast would mean adjusting the |
What
AvatarGroupOverflowgrows into a pill for long+Ncounts so the number never clips.Previously the indicator was a fixed-size circle (
width: size; height: size). With larger counts (e.g.+4912) the text was wider than the circle and clipped/crowded the edges.Now the indicator:
Short counts (
+5) stay a perfect circle; longer counts grow horizontally into a stadium/pill. The full radius on a wider-than-tall box yields the pill shape automatically — no new public prop.Why
Hardening/style fix: the component already claims to support arbitrary counts, but the fixed circle broke the "long content" overflow case for multi-digit numbers.
Testing
pnpm build— passpnpm test— pass (added a test asserting the full+4912text renders and its accessible label is intact)pnpm lint— passCircleToPillStorybook story showing+5(circle) next to+4912(pill) so the difference is visible.paddingshorthand topaddingBlock: 0so the pill's horizontal breathing room survives.Closes #4167