File tree 1 file changed +11
-3
lines changed
packages/module/src/Message
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -81,8 +81,16 @@ export const Message: React.FunctionComponent<MessageProps> = ({
81
81
onAttachmentClose && attachmentId && onAttachmentClose ( attachmentId ) ;
82
82
} ;
83
83
84
+ // Keep timestamps consistent between Timestamp component and aria-label
85
+ const date = new Date ( ) ;
86
+ const dateString = timestamp ?? `${ date . toLocaleDateString ( ) } ${ date . toLocaleTimeString ( ) } ` ;
87
+
84
88
return (
85
- < div className = { `pf-chatbot__message pf-chatbot__message--${ role } ` } { ...props } >
89
+ < section
90
+ aria-label = { `Message from ${ role } - ${ dateString } ` }
91
+ className = { `pf-chatbot__message pf-chatbot__message--${ role } ` }
92
+ { ...props }
93
+ >
86
94
{ /* We are using an empty alt tag intentionally in order to reduce noise on screen readers */ }
87
95
< Avatar src = { avatar ?? DEFAULTS [ role ] . avatar } alt = "" />
88
96
< div className = "pf-chatbot__message-contents" >
@@ -93,7 +101,7 @@ export const Message: React.FunctionComponent<MessageProps> = ({
93
101
AI
94
102
</ Label >
95
103
) }
96
- < Timestamp > { timestamp } </ Timestamp >
104
+ < Timestamp date = { date } > { timestamp } </ Timestamp >
97
105
</ div >
98
106
< div className = "pf-chatbot__message-response" >
99
107
< div className = "pf-chatbot__message-and-actions" >
@@ -114,7 +122,7 @@ export const Message: React.FunctionComponent<MessageProps> = ({
114
122
) }
115
123
</ div >
116
124
</ div >
117
- </ div >
125
+ </ section >
118
126
) ;
119
127
} ;
120
128
You can’t perform that action at this time.
0 commit comments