Skip to content

Commit

Permalink
Conditionaly render announcers (#5526)
Browse files Browse the repository at this point in the history
* Conditionaly render announcers

* change
  • Loading branch information
dmceachernmsft authored Dec 27, 2024
1 parent bbb1ac1 commit 9f581b3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "patch",
"area": "fix",
"workstream": "A11y",
"comment": "Change the announcers in the Mic and Camera button to be conditionally rendered to stop them being read in scan mode if the button isn't focused",
"packageName": "@azure/communication-react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "patch",
"area": "fix",
"workstream": "A11y",
"comment": "Change the announcers in the Mic and Camera button to be conditionally rendered to stop them being read in scan mode if the button isn't focused",
"packageName": "@azure/communication-react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
5 changes: 4 additions & 1 deletion packages/react-components/src/components/CameraButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export const CameraButton = (props: CameraButtonProps): JSX.Element => {
const localeStrings = useLocale().strings.cameraButton;
const strings = { ...localeStrings, ...props.strings };
const [announcerString, setAnnouncerString] = useState<string | undefined>(undefined);
const [announcerPresent, setAnnouncerPresent] = useState<boolean>(false);

const disabled = props.disabled || waitForCamera;

Expand Down Expand Up @@ -297,7 +298,7 @@ export const CameraButton = (props: CameraButtonProps): JSX.Element => {

return (
<>
<Announcer announcementString={announcerString} ariaLive={'polite'} />
{announcerPresent && <Announcer announcementString={announcerString} ariaLive={'polite'} />}
<ControlBarButton
{...props}
disabled={disabled}
Expand All @@ -323,6 +324,8 @@ export const CameraButton = (props: CameraButtonProps): JSX.Element => {
ariaLabel={ariaLabel}
splitButtonAriaLabel={props.enableDeviceSelectionMenu ? splitButtonAriaString : undefined}
splitButtonMenuProps={splitButtonMenuProps}
onFocus={() => setAnnouncerPresent(true)}
onBlur={() => setAnnouncerPresent(false)}
/>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export const MicrophoneButton = (props: MicrophoneButtonProps): JSX.Element => {
const localeStrings = useLocale().strings.microphoneButton;
const strings = { ...localeStrings, ...props.strings };
const [announcerString, setAnnouncerString] = useState<string | undefined>(undefined);
const [announcerPresent, setAnnouncerPresent] = useState<boolean>(false);

const isSplit = props.split ?? props.enableDeviceSelectionMenu;

Expand Down Expand Up @@ -313,7 +314,7 @@ export const MicrophoneButton = (props: MicrophoneButtonProps): JSX.Element => {

return (
<>
<Announcer announcementString={announcerString} ariaLive={'polite'} />
{announcerPresent && <Announcer announcementString={announcerString} ariaLive={'polite'} />}
<ControlBarButton
{...props}
onClick={props.onToggleMicrophone ? onToggleClick : props.onClick}
Expand All @@ -340,6 +341,8 @@ export const MicrophoneButton = (props: MicrophoneButtonProps): JSX.Element => {
splitButtonAriaLabel={props.enableDeviceSelectionMenu ? splitButtonAriaString : undefined}
disabled={disabled}
primaryDisabled={primaryDisabled}
onFocus={() => setAnnouncerPresent(true)}
onBlur={() => setAnnouncerPresent(false)}
/>
</>
);
Expand Down

0 comments on commit 9f581b3

Please sign in to comment.