Skip to content

Commit 251ae95

Browse files
committed
fix(Message): Switch to alt='' for avatars
Eric notes that these avatars would be noise if the chat goes on a long time. This is a more decorative element. With this change, screenreaders won't mention the avatars.
1 parent a0c2270 commit 251ae95

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

packages/module/src/Message/Message.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ export interface MessageProps extends Omit<React.HTMLProps<HTMLDivElement>, 'rol
2525
name?: string;
2626
/** Avatar src for the user */
2727
avatar?: string;
28-
/** Alt text placed on the avatar */
29-
avatarAltText?: string;
3028
/** Timestamp for the message */
3129
timestamp?: string;
3230
/** Set this to true if message is being loaded */
@@ -63,7 +61,6 @@ export const Message: React.FunctionComponent<MessageProps> = ({
6361
onAttachmentClose,
6462
actions,
6563
sources,
66-
avatarAltText,
6764
...props
6865
}: MessageProps) => {
6966
// Configure default values
@@ -86,7 +83,8 @@ export const Message: React.FunctionComponent<MessageProps> = ({
8683

8784
return (
8885
<div className={`pf-chatbot__message pf-chatbot__message--${role}`} {...props}>
89-
<Avatar src={avatar ?? DEFAULTS[role].avatar} alt={avatarAltText || `Profile picture of ${role}`} />
86+
{/* We are using an empty alt tag intentionally in order to reduce noise on screen readers */}
87+
<Avatar src={avatar ?? DEFAULTS[role].avatar} alt="" />
9088
<div className="pf-chatbot__message-contents">
9189
<div className="pf-chatbot__message-meta">
9290
<span className="pf-chatbot__message-name">{name}</span>

0 commit comments

Comments
 (0)