Skip to content

Commit 04956d7

Browse files
Post-review adjustments
1 parent d947464 commit 04956d7

3 files changed

Lines changed: 14 additions & 15 deletions

File tree

src/components/Avatar/Avatar.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const Avatar = ({
5353
className,
5454
FallbackIcon = IconUser,
5555
imageUrl,
56+
initials: customInitials,
5657
isOnline,
5758
size,
5859
userName,
@@ -63,17 +64,16 @@ export const Avatar = ({
6364
useEffect(() => () => setError(false), [imageUrl]);
6465

6566
const nameString = userName?.toString().trim() || '';
66-
const avatarImageAlt = nameString.trim();
6767

6868
const sizeAwareInitials = useMemo(() => {
69-
const initials = rest.initials || getInitials(nameString);
69+
const initials = customInitials || getInitials(nameString);
7070

7171
if (size === 'sm' || size === 'xs') {
7272
return initials.charAt(0);
7373
}
7474

7575
return initials;
76-
}, [nameString, size, rest.initials]);
76+
}, [nameString, size, customInitials]);
7777

7878
const showImage = typeof imageUrl === 'string' && imageUrl && !error;
7979

@@ -100,7 +100,7 @@ export const Avatar = ({
100100
)}
101101
{showImage ? (
102102
<img
103-
alt={avatarImageAlt}
103+
alt={nameString}
104104
className='str-chat__avatar-image'
105105
data-testid='avatar-img'
106106
onError={() => setError(true)}

src/components/TextareaComposer/SuggestionList/MentionItem/UserItem.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ export const UserItem = ({ entity, focused, ...buttonProps }: UserItemProps) =>
3232
const hasEntity = !!Object.keys(entity).length;
3333

3434
const titleAttribute = entity.name || entity.id || '';
35-
const displayInfo = extractDisplayInfo({ user: entity });
36-
const LeadingSlot = useMemo(
37-
() =>
38-
function UserItemAvatar() {
39-
// Decorative: the option's accessible name already carries the user's name (title +
40-
// tokenized display name), so the avatar's fallback initials/role would only add noise.
41-
return <Avatar {...displayInfo} aria-hidden size='md' />;
42-
},
43-
[Avatar, displayInfo],
44-
);
35+
const LeadingSlot = useMemo(() => {
36+
const displayInfo = extractDisplayInfo({ user: entity });
37+
38+
return function UserItemAvatar() {
39+
// Decorative: the option's accessible name already carries the user's name (title +
40+
// tokenized display name), so the avatar's fallback initials/role would only add noise.
41+
return <Avatar {...displayInfo} aria-hidden size='md' />;
42+
};
43+
}, [Avatar, entity, extractDisplayInfo]);
4544

4645
if (!hasEntity) return null;
4746

src/plugins/ChannelDetail/Views/ChannelMembersView/ChannelMembersAddView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const ChannelMembersAddViewItem = ({
7272
function MemberAvatar() {
7373
return <Avatar {...displayInfo} isOnline={user.online} size='md' />;
7474
},
75-
[Avatar, displayInfo, user.online],
75+
[Avatar, displayInfo, user],
7676
);
7777

7878
const SelectableTrailingSlot = useMemo(

0 commit comments

Comments
 (0)