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) Make the video menu HTML valid for accessibility

raduanastase8x888b45c918225
diff --git a/react/features/base/popover/components/Popover.web.tsx b/react/features/base/popover/components/Popover.web.tsx
index 9f1c2c67fe..0052f2765f 100644
--- a/react/features/base/popover/components/Popover.web.tsx
+++ b/react/features/base/popover/components/Popover.web.tsx
@@ -88,6 +88,11 @@ interface IProps {
*/
position: string;
+ /**
+ * The ARIA role.
+ */
+ role?: string;
+
/**
* Whether the trigger for open/ close should be click or hover.
*/
@@ -483,20 +488,24 @@ class Popover extends Component<IProps, IState> {
* @returns {ReactElement}
*/
_renderContent() {
- const { content, position, trigger, headingId, headingLabel } = this.props;
+ const { content, position, trigger, headingId, headingLabel, role = 'dialog' } = this.props;
+ const isFocusLockEnabled = this.state.enableFocusLock;
+ const isDialogRole = role === 'dialog';
return (
<div className = { `popover ${trigger}` }>
<div
className = { `popover-content ${position.split('-')[0]}` }
- data-autofocus = { this.state.enableFocusLock }
+ data-autofocus = { isFocusLockEnabled }
onKeyDown = { this._onEscKey }
- { ...(this.state.enableFocusLock && {
+ { ...(isFocusLockEnabled && {
+ role,
+ tabIndex: -1
+ }) }
+ { ...(isFocusLockEnabled && isDialogRole && {
'aria-modal': true,
'aria-label': !headingId && headingLabel ? headingLabel : undefined,
- 'aria-labelledby': headingId,
- role: 'dialog',
- tabIndex: -1
+ 'aria-labelledby': headingId ? headingId : undefined
}) }>
{ content }
</div>
diff --git a/react/features/base/ui/components/web/ContextMenuItem.tsx b/react/features/base/ui/components/web/ContextMenuItem.tsx
index e41352f95b..8cd61981fa 100644
--- a/react/features/base/ui/components/web/ContextMenuItem.tsx
+++ b/react/features/base/ui/components/web/ContextMenuItem.tsx
@@ -224,7 +224,7 @@ const ContextMenuItem = ({
tabIndex = selected ? 0 : -1;
}
- if (role === 'button' && !disabled) {
+ if ((role === 'button' || role === 'menuitem') && !disabled) {
tabIndex = 0;
}
diff --git a/react/features/base/ui/components/web/ContextMenuItemGroup.tsx b/react/features/base/ui/components/web/ContextMenuItemGroup.tsx
index 6e54ee6d77..004e1a3ff4 100644
--- a/react/features/base/ui/components/web/ContextMenuItemGroup.tsx
+++ b/react/features/base/ui/components/web/ContextMenuItemGroup.tsx
@@ -15,6 +15,11 @@ interface IProps {
* The children of the component.
*/
children?: ReactNode;
+
+ /**
+ * The optional role of the component.
+ */
+ role?: string;
}
const useStyles = makeStyles()(theme => {
@@ -41,12 +46,15 @@ const useStyles = makeStyles()(theme => {
const ContextMenuItemGroup = ({
actions,
- children
+ children,
+ ...rest
}: IProps) => {
const { classes: styles } = useStyles();
return (
- <div className = { styles.contextMenuItemGroup }>
+ <div
+ className = { styles.contextMenuItemGroup }
+ { ...rest }>
{children}
{actions?.map(actionProps => (
<ContextMenuItem
diff --git a/react/features/settings/components/web/video/VideoSettingsContent.tsx b/react/features/settings/components/web/video/VideoSettingsContent.tsx
index 00bfc8206e..c77be499e4 100644
--- a/react/features/settings/components/web/video/VideoSettingsContent.tsx
+++ b/react/features/settings/components/web/video/VideoSettingsContent.tsx
@@ -257,6 +257,7 @@ const VideoSettingsContent = ({
previewProps['aria-checked'] = true;
previewProps.className = cx(classes.previewEntry, classes.selectedEntry);
} else {
+ previewProps['aria-checked'] = false;
previewProps.onClick = _onEntryClick(deviceId);
previewProps.onKeyPress = (e: React.KeyboardEvent) => {
if (e.key === ' ' || e.key === 'Enter') {
@@ -269,7 +270,7 @@ const VideoSettingsContent = ({
return (
<div
{ ...previewProps }
- role = 'radio'>
+ role = 'menuitemradio'>
<div className = { classes.labelContainer }>
{label && <div className = { classes.label }>
<span>{label}</span>
@@ -303,25 +304,24 @@ const VideoSettingsContent = ({
return (
<ContextMenu
activateFocusTrap = { true }
- aria-labelledby = 'video-settings-button'
className = { classes.container }
hidden = { false }
- id = 'video-settings-dialog'
- role = 'radiogroup'
- tabIndex = { -1 }>
- <ContextMenuItemGroup>
+ id = 'video-settings-dialog'>
+ <ContextMenuItemGroup role = 'group'>
{trackData.map((data, i) => _renderPreviewEntry(data, i))}
</ContextMenuItemGroup>
- <ContextMenuItemGroup>
+ <ContextMenuItemGroup role = 'group'>
{ visibleVirtualBackground && <ContextMenuItem
accessibilityLabel = { t('virtualBackground.title') }
icon = { IconImage }
onClick = { selectBackground }
+ role = 'menuitem'
text = { t('virtualBackground.title') } /> }
{!disableLocalVideoFlip && (
<div
className = { classes.checkboxContainer }
- onClick = { stopPropagation }>
+ onClick = { stopPropagation }
+ role = 'menuitem'>
<Checkbox
checked = { localFlipX }
label = { t('videothumbnail.mirrorVideo') }
diff --git a/react/features/settings/components/web/video/VideoSettingsPopup.tsx b/react/features/settings/components/web/video/VideoSettingsPopup.tsx
index 1d82cc08fc..e0d29b1389 100644
--- a/react/features/settings/components/web/video/VideoSettingsPopup.tsx
+++ b/react/features/settings/components/web/video/VideoSettingsPopup.tsx
@@ -93,6 +93,7 @@ function VideoSettingsPopup({
headingId = 'video-settings-button'
onPopoverClose = { onClose }
position = { popupPlacement }
+ role = 'menu'
trigger = 'click'
visible = { isOpen }>
{ children }