Skip to content

Commit

Permalink
fix(chat): restructure chat messages
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Irmer <[email protected]>
  • Loading branch information
joshuai96 committed Feb 26, 2025
1 parent ee6bf01 commit 00c7142
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
17 changes: 15 additions & 2 deletions react/features/base/react/components/web/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ interface IProps {
*/
gifEnabled: boolean;

/**
* Message decoration for screen reader.
*/
screenReaderHelpText?: string;

/**
* The body of the message.
*/
Expand Down Expand Up @@ -91,10 +96,18 @@ class Message extends Component<IProps> {
* @returns {ReactElement}
*/
render() {
const { screenReaderHelpText } = this.props;

return (
<>
<p>
{ screenReaderHelpText && (
<span className = 'sr-only'>
{screenReaderHelpText}
</span>
) }

{ this._processMessage() }
</>
</p>
);
}
}
Expand Down
33 changes: 18 additions & 15 deletions react/features/chat/components/web/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ const ChatMessage = ({
function _renderTimestamp() {
return (
<div className = { cx('timestamp', classes.timestamp) }>
{getFormattedTimestamp(message)}
<p>
{getFormattedTimestamp(message)}
</p>
</div>
);
}
Expand Down Expand Up @@ -285,15 +287,17 @@ const ChatMessage = ({
<div
className = { classes.reactionItem }
key = { reaction }>
<span>{reaction}</span>
<span>{participants.size}</span>
<p>
<span>{reaction}</span>
<span>{participants.size}</span>
</p>
<div className = { classes.participantList }>
{Array.from(participants).map(participantId => (
<div
<p
className = { classes.participant }
key = { participantId }>
{state && getParticipantDisplayName(state, participantId)}
</div>
</p>
))}
</div>
</div>
Expand All @@ -311,12 +315,12 @@ const ChatMessage = ({
visible = { isReactionsOpen }>
<div className = { classes.reactionBox }>
{reactionsArray.slice(0, numReactionsDisplayed).map(({ reaction }, index) =>
<span key = { index }>{reaction}</span>
<p key = { index }>{reaction}</p>
)}
{reactionsArray.length > numReactionsDisplayed && (
<span className = { classes.reactionCount }>
<p className = { classes.reactionCount }>
+{totalReactions - numReactionsDisplayed}
</span>
</p>
)}
</div>
</Popover>
Expand Down Expand Up @@ -352,14 +356,13 @@ const ChatMessage = ({
<div className = { cx('messagecontent', classes.messageContent) }>
{showDisplayName && _renderDisplayName()}
<div className = { cx('usermessage', classes.userMessage) }>
<span className = 'sr-only'>
{message.displayName === message.recipient
? t('chat.messageAccessibleTitleMe')
: t('chat.messageAccessibleTitle', {
<Message
screenReaderHelpText = { message.displayName === message.recipient
? t<string>('chat.messageAccessibleTitleMe')
: t<string>('chat.messageAccessibleTitle', {
user: message.displayName
})}
</span>
<Message text = { getMessageText(message) } />
}) }
text = { getMessageText(message) } />
{(message.privateMessage || (message.lobbyChat && !knocking))
&& _renderPrivateNotice()}
<div className = { classes.chatMessageFooter }>
Expand Down

0 comments on commit 00c7142

Please sign in to comment.