diff --git a/app/components/Facepile.tsx b/app/components/Facepile.tsx index ca0d90f66e..c2d8f12753 100644 --- a/app/components/Facepile.tsx +++ b/app/components/Facepile.tsx @@ -37,10 +37,16 @@ function Facepile({ ...rest }: Props) { const { t } = useTranslation(); - const filtered = users.filter(Boolean).slice(-limit); + const present = users.filter(Boolean); + // A "+1" badge takes up the same space as an avatar, so when the single + // overflowing user is actually present in the list, show their avatar + // instead. Fall back to the badge when the overflow comes from a separate + // total count and the extra user isn't available to render. + const showLastInsteadOfBadge = overflow === 1 && present.length - limit === 1; + const filtered = present.slice(-(showLastInsteadOfBadge ? limit + 1 : limit)); const Component = renderAvatar; - if (overflow > 0) { + if (overflow > 0 && !showLastInsteadOfBadge) { filtered.unshift({ id: "overflow", initial: `${users.length ? "+" : ""}${overflow}`,