Skip to content

Commit 075b95f

Browse files
Fix an issue where system chat messages weren't announced (#5463)
1 parent 60bded3 commit 075b95f

3 files changed

Lines changed: 38 additions & 7 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "A11y",
5+
"comment": "Fix an issue where system chat messages weren't announced",
6+
"packageName": "@azure/communication-react",
7+
"email": "98852890+vhuseinova-msft@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "A11y",
5+
"comment": "Fix an issue where system chat messages weren't announced",
6+
"packageName": "@azure/communication-react",
7+
"email": "98852890+vhuseinova-msft@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}

packages/react-components/src/components/SystemMessage.tsx

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
// Licensed under the MIT License.
33

44
import { IStyle, FontIcon, mergeStyles, Stack, Text } from '@fluentui/react';
5-
import React from 'react';
5+
import React, { useEffect, useState } from 'react';
66
import { systemMessageIconStyle } from './styles/SystemMessage.styles';
77
import { ComponentSlotStyle } from '../types';
8+
import LiveMessage from './Announcer/LiveMessage';
89

910
/**
1011
* Todo: We need to add more types of system messages that we support.
@@ -37,13 +38,25 @@ export type SystemMessageProps = {
3738
export const SystemMessage = (props: SystemMessageProps): JSX.Element => {
3839
const { iconName, content } = props;
3940
const Icon: JSX.Element = <FontIcon iconName={iconName} className={mergeStyles(systemMessageIconStyle)} />;
41+
const [liveMessage, setLiveMessage] = useState('');
42+
43+
useEffect(() => {
44+
// Timeout is needed to handle situation when the same user joins and leaves a chat a few times in a row, otherwise Narrator won't repeat the system message text.
45+
// Because delay value is not provided, setMessage function will be executed asynchronously in the next event cycle
46+
setTimeout(() => {
47+
setLiveMessage(content);
48+
});
49+
}, [content]);
4050

4151
return (
42-
<Stack horizontal className={mergeStyles(props?.containerStyle as IStyle)} tabIndex={0}>
43-
{Icon}
44-
<Text style={{ wordBreak: 'break-word' }} role="status" title={content} variant={'small'}>
45-
{content}
46-
</Text>
47-
</Stack>
52+
<>
53+
<LiveMessage message={liveMessage} ariaLive="polite" clearOnUnmount={true} />
54+
<Stack horizontal className={mergeStyles(props?.containerStyle as IStyle)} tabIndex={0}>
55+
{Icon}
56+
<Text style={{ wordBreak: 'break-word' }} role="status" title={content} variant={'small'}>
57+
{content}
58+
</Text>
59+
</Stack>
60+
</>
4861
);
4962
};

0 commit comments

Comments
 (0)