fix: Avoid pointless +1 on Facepile (#12823)

* Avoid +1 on facepile

* revert

* feedback
This commit is contained in:
Tom Moor authored and GitHub committed 2026-06-24 21:50:10 -04:00
1 parent 79d646b904
commit b8ed9be236
1 file changed
+8 -2
+8 -2
View File
@@ -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}`,