Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

chore(wcag) Create valid structure for audio menu (#16007)

raduanastase8x852fa36f930ae
diff --git a/react/features/base/ui/components/web/ContextMenuItem.tsx b/react/features/base/ui/components/web/ContextMenuItem.tsx
index 8cd61981fa..96b7db0caa 100644
--- a/react/features/base/ui/components/web/ContextMenuItem.tsx
+++ b/react/features/base/ui/components/web/ContextMenuItem.tsx
@@ -14,7 +14,7 @@ export interface IProps {
/**
* Label used for accessibility.
*/
- accessibilityLabel: string;
+ accessibilityLabel?: string;
/**
* The context menu item background color.
@@ -232,7 +232,7 @@ const ContextMenuItem = ({
<div
aria-controls = { controls }
aria-disabled = { disabled }
- aria-label = { accessibilityLabel }
+ aria-label = { accessibilityLabel || undefined }
aria-selected = { role === 'tab' ? selected : undefined }
className = { cx(styles.contextMenuItem,
_overflowDrawer && styles.contextMenuItemDrawer,
diff --git a/react/features/settings/components/web/audio/AudioSettingsContent.tsx b/react/features/settings/components/web/audio/AudioSettingsContent.tsx
index d966190398..4bd43f5c6b 100644
--- a/react/features/settings/components/web/audio/AudioSettingsContent.tsx
+++ b/react/features/settings/components/web/audio/AudioSettingsContent.tsx
@@ -286,37 +286,36 @@ const AudioSettingsContent = ({
className = { classes.contextMenu }
hidden = { false }
id = 'audio-settings-dialog'
+ role = 'menu'
tabIndex = { -1 }>
- <ContextMenuItemGroup>
+ <ContextMenuItemGroup
+ aria-labelledby = { microphoneHeaderId }
+ role = 'group'>
<ContextMenuItem
- accessibilityLabel = { t('settings.microphones') }
className = { classes.header }
icon = { IconMic }
id = { microphoneHeaderId }
text = { t('settings.microphones') } />
<ul
- aria-labelledby = { microphoneHeaderId }
className = { classes.list }
- role = 'radiogroup'
- tabIndex = { -1 }>
+ role = 'presentation'>
{audioTracks.map((data, i) =>
_renderMicrophoneEntry(data, i, audioTracks.length)
)}
</ul>
</ContextMenuItemGroup>
{outputDevices.length > 0 && (
- <ContextMenuItemGroup>
+ <ContextMenuItemGroup
+ aria-labelledby = { speakerHeaderId }
+ role = 'group'>
<ContextMenuItem
- accessibilityLabel = { t('settings.speakers') }
className = { classes.header }
icon = { IconVolumeUp }
id = { speakerHeaderId }
text = { t('settings.speakers') } />
<ul
- aria-labelledby = { speakerHeaderId }
className = { classes.list }
- role = 'radiogroup'
- tabIndex = { -1 }>
+ role = 'presentation'>
{outputDevices.map((data: any, i: number) =>
_renderSpeakerEntry(data, i, outputDevices.length)
)}
diff --git a/react/features/settings/components/web/audio/MicrophoneEntry.tsx b/react/features/settings/components/web/audio/MicrophoneEntry.tsx
index 7464c507b2..b586d5284d 100644
--- a/react/features/settings/components/web/audio/MicrophoneEntry.tsx
+++ b/react/features/settings/components/web/audio/MicrophoneEntry.tsx
@@ -196,10 +196,9 @@ const MicrophoneEntry = ({
className = { classes.container }
onClick = { onClick }
onKeyPress = { onKeyPress }
- role = 'radio'
+ role = 'menuitemradio'
tabIndex = { 0 }>
<ContextMenuItem
- accessibilityLabel = { children }
icon = { isSelected ? IconCheck : undefined }
overflowType = { TEXT_OVERFLOW_TYPES.SCROLL_ON_HOVER }
selected = { isSelected }
diff --git a/react/features/settings/components/web/audio/SpeakerEntry.tsx b/react/features/settings/components/web/audio/SpeakerEntry.tsx
index 489d3926a5..49d22cb834 100644
--- a/react/features/settings/components/web/audio/SpeakerEntry.tsx
+++ b/react/features/settings/components/web/audio/SpeakerEntry.tsx
@@ -1,4 +1,5 @@
import React, { useRef } from 'react';
+import { useTranslation } from 'react-i18next';
import { makeStyles } from 'tss-react/mui';
import { IconCheck } from '../../../../base/icons/svg';
@@ -91,6 +92,7 @@ const useStyles = makeStyles()(() => {
const SpeakerEntry = (props: IProps) => {
const audioRef = useRef<HTMLAudioElement | null>(null);
const { classes, cx } = useStyles();
+ const { t } = useTranslation();
/**
* Click handler for the entry.
@@ -135,39 +137,38 @@ const SpeakerEntry = (props: IProps) => {
}
const { children, isSelected, index, length } = props;
+ const testLabel = t('deviceSelection.testAudio');
/* eslint-disable react/jsx-no-bind */
return (
- <span
+ <li
+ aria-checked = { isSelected }
+ aria-label = { children }
+ aria-posinset = { index + 1 } // Add one to offset the 0 based index.
+ aria-setsize = { length }
className = { classes.container }
- role = 'presentation'>
- <li
- aria-checked = { isSelected }
- aria-posinset = { index + 1 } // Add one to offset the 0 based index.
- aria-setsize = { length }
- onClick = { _onClick }
- onKeyPress = { _onKeyPress }
- role = 'radio'
- tabIndex = { 0 }>
- <ContextMenuItem
- accessibilityLabel = { children }
- icon = { isSelected ? IconCheck : undefined }
- overflowType = { TEXT_OVERFLOW_TYPES.SCROLL_ON_HOVER }
- selected = { isSelected }
- text = { children }
- textClassName = { cx(classes.entryText, 'entryText', !isSelected && 'left-margin') } />
- <audio
- preload = 'auto'
- ref = { audioRef }
- src = { TEST_SOUND_PATH } />
- </li>
+ onClick = { _onClick }
+ onKeyPress = { _onKeyPress }
+ role = 'menuitemradio'
+ tabIndex = { 0 }>
+ <ContextMenuItem
+ icon = { isSelected ? IconCheck : undefined }
+ overflowType = { TEXT_OVERFLOW_TYPES.SCROLL_ON_HOVER }
+ selected = { isSelected }
+ text = { children }
+ textClassName = { cx(classes.entryText, 'entryText', !isSelected && 'left-margin') } />
+ <audio
+ preload = 'auto'
+ ref = { audioRef }
+ src = { TEST_SOUND_PATH } />
<Button
+ accessibilityLabel = { `${testLabel} ${children}` }
className = { cx(classes.testButton, 'testButton') }
- label = 'Test'
+ label = { testLabel }
onClick = { _onTestButtonClick }
onKeyPress = { _onTestButtonClick }
type = { BUTTON_TYPES.SECONDARY } />
- </span>
+ </li>
);
};