Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/ui/src/avatar/avatar-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ export const AvatarGroup: React.FC<Props> = (props) => {
// calculate total length of avatars inside the group
const totalAvatars = React.Children.toArray(children).length;

// if avatars are equal to max + 1, then we need to show the last avatar as well, if avatars are more than max + 1, then we need to show the count of the remaining avatars
const maxAvatarsToRender = totalAvatars <= max + 1 ? max + 1 : max;

// slice the children to the maximum number of avatars
const avatars = React.Children.toArray(children).slice(0, max);
const avatars = React.Children.toArray(children).slice(0, maxAvatarsToRender);

// assign the necessary props from the AvatarGroup component to the Avatar components
const avatarsWithUpdatedProps = avatars.map((avatar) => {
Expand All @@ -58,7 +61,7 @@ export const AvatarGroup: React.FC<Props> = (props) => {
{avatar}
</div>
))}
{max < totalAvatars && (
{maxAvatarsToRender < totalAvatars && (
<Tooltip
tooltipContent={`${totalAvatars} total`}
disabled={!showTooltip}
Expand Down