Skip to content

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

Improve accessibility in breakout rooms list (#13669)

AHMAD KADRI58115477a2e4
diff --git a/lang/main-de.json b/lang/main-de.json
index 963c00cafc..12428d4486 100644
--- a/lang/main-de.json
+++ b/lang/main-de.json
@@ -67,13 +67,16 @@
"renameBreakoutRoom": "Breakout-Raum umbenennen",
"sendToBreakoutRoom": "Anwesende in Breakout-Raum verschieben:"
},
+ "breakoutList": "Breakout-Liste",
"defaultName": "Breakout-Raum #{{index}}",
+ "hideParticipantList": "Teilnehmerliste ausblenden",
"mainRoom": "Hauptraum",
"notifications": {
"joined": "Breakout-Raum \"{{name}}\" betreten",
"joinedMainRoom": "Hauptraum betreten",
"joinedTitle": "Breakout-Räume"
- }
+ },
+ "showParticipantList": "Teilnehmerliste anzeigen"
},
"calendarSync": {
"addMeetingURL": "Konferenzlink hinzufügen",
diff --git a/lang/main.json b/lang/main.json
index 3bf33bec1b..8eac4ee7ee 100644
--- a/lang/main.json
+++ b/lang/main.json
@@ -67,13 +67,16 @@
"renameBreakoutRoom": "Rename breakout room",
"sendToBreakoutRoom": "Send participant to:"
},
+ "breakoutList": "breakout list",
"defaultName": "Breakout room #{{index}}",
+ "hideParticipantList": "Hide participant list",
"mainRoom": "Main room",
"notifications": {
"joined": "Joining the \"{{name}}\" breakout room",
"joinedMainRoom": "Joining the main room",
"joinedTitle": "Breakout Rooms"
- }
+ },
+ "showParticipantList": "Show participant list"
},
"calendarSync": {
"addMeetingURL": "Add a meeting link",
diff --git a/react/features/base/ui/components/web/ContextMenu.tsx b/react/features/base/ui/components/web/ContextMenu.tsx
index fbf07f9e84..3f46244d3b 100644
--- a/react/features/base/ui/components/web/ContextMenu.tsx
+++ b/react/features/base/ui/components/web/ContextMenu.tsx
@@ -1,4 +1,6 @@
-import React, { ReactNode, useEffect, useLayoutEffect, useRef, useState } from 'react';
+import React, { KeyboardEvent, ReactNode,
+ useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
+import { FocusOn } from 'react-focus-on';
import { useSelector } from 'react-redux';
import { makeStyles } from 'tss-react/mui';
@@ -9,6 +11,7 @@ import participantsPaneTheme from '../../../components/themes/participantsPaneTh
import { withPixelLineHeight } from '../../../styles/functions.web';
import { spacing } from '../../Tokens';
+
/**
* Get a style property from a style declaration as a float.
*
@@ -45,6 +48,11 @@ interface IProps {
*/
accessibilityLabel?: string;
+ /**
+ * To activate the FocusOn component.
+ */
+ activateFocusTrap?: boolean;
+
/**
* Children of the context menu.
*/
@@ -163,6 +171,7 @@ const useStyles = makeStyles()(theme => {
const ContextMenu = ({
accessibilityLabel,
+ activateFocusTrap = false,
children,
className,
entity,
@@ -227,6 +236,133 @@ const ContextMenu = ({
}
}, [ hidden ]);
+ const handleKeyDown = useCallback((event: KeyboardEvent) => {
+ const { current: listRef } = containerRef;
+ const currentFocusElement = document.activeElement;
+
+ const moveFocus = (
+ list: Element | null,
+ currentFocus: Element | null,
+ traversalFunction: (
+ list: Element | null,
+ currentFocus: Element | null
+ ) => Element | null
+ ) => {
+ let wrappedOnce = false;
+ let nextFocus = traversalFunction(list, currentFocus);
+
+ /* eslint-disable no-unmodified-loop-condition */
+ while (list && nextFocus) {
+ // Prevent infinite loop.
+ if (nextFocus === list.firstChild) {
+ if (wrappedOnce) {
+ return;
+ }
+ wrappedOnce = true;
+ }
+
+ // Same logic as useAutocomplete.js
+ const nextFocusDisabled
+ /* eslint-disable no-extra-parens */
+ = (nextFocus as HTMLInputElement).disabled
+ || nextFocus.getAttribute('aria-disabled') === 'true';
+
+ if (!nextFocus.hasAttribute('tabindex') || nextFocusDisabled) {
+ // Move to the next element.
+ nextFocus = traversalFunction(list, nextFocus);
+ } else {
+ /* eslint-disable no-extra-parens */
+ (nextFocus as HTMLElement).focus();
+
+ return;
+ }
+ }
+ };
+
+ const previousItem = (
+ list: Element | null,
+ item: Element | null
+ ): Element | null => {
+ /**
+ * To find the last child of the list.
+ *
+ * @param {Element | null} element - Element.
+ * @returns {Element | null}
+ */
+ function lastChild(element: Element | null): Element | null {
+ while (element?.lastElementChild) {
+ /* eslint-disable no-param-reassign */
+ element = element.lastElementChild;
+ }
+
+ return element;
+ }
+
+ if (!list) {
+ return null;
+ }
+ if (list === item) {
+ return list.lastElementChild;
+ }
+ if (item?.previousElementSibling) {
+ return lastChild(item.previousElementSibling);
+ }
+ if (item && item?.parentElement !== list) {
+ return item.parentElement;
+ }
+
+ return lastChild(list.lastElementChild);
+ };
+
+ const nextItem = (
+ list: Element | null,
+ item: Element | null
+ ): Element | null => {
+ if (!list) {
+ return null;
+ }
+
+ if (list === item) {
+ return list.firstElementChild;
+ }
+ if (item?.firstElementChild) {
+ return item.firstElementChild;
+ }
+ if (item?.nextElementSibling) {
+ return item.nextElementSibling;
+ }
+ while (item && item.parentElement !== list) {
+ /* eslint-disable no-param-reassign */
+ item = item.parentElement;
+ if (item?.nextElementSibling) {
+ return item.nextElementSibling;
+ }
+ }
+
+ return list?.firstElementChild;
+ };
+
+ if (event.key === 'Escape') {
+ // Close the menu
+ event.preventDefault();
+ setIsHidden(true);
+
+ } else if (event.key === 'ArrowUp') {
+ // Move focus to the previous menu item
+ event.preventDefault();
+ moveFocus(listRef, currentFocusElement, previousItem);
+
+ } else if (event.key === 'ArrowDown') {
+ // Move focus to the next menu item
+ event.preventDefault();
+ moveFocus(listRef, currentFocusElement, nextItem);
+ }
+ }, [ containerRef ]);
+
+ const removeFocus = useCallback(() => {
+ onDrawerClose?.();
+ }, [ onMouseLeave ]);
+
if (_overflowDrawer && inDrawer) {
return (<div
className = { styles.drawer }
@@ -247,23 +383,32 @@ const ContextMenu = ({
</div>
</Drawer>
</JitsiPortal>
- : <div
- { ...aria }
- aria-label = { accessibilityLabel }
- className = { cx(styles.contextMenu,
+ : <FocusOn
+
+ // Use the `enabled` prop instead of conditionally rendering ReactFocusOn
+ // to prevent UI stutter on dialog appearance. It seems the focus guards generated annoy
+ // our DialogPortal positioning calculations.
+ enabled = { activateFocusTrap && !isHidden }
+ onClickOutside = { removeFocus }
+ onEscapeKey = { removeFocus }>
+ <div
+ { ...aria }
+ aria-label = { accessibilityLabel }
+ className = { cx(styles.contextMenu,
isHidden && styles.contextMenuHidden,
className
- ) }
- id = { id }
- onClick = { onClick }
- onKeyDown = { onKeyDown }
- onMouseEnter = { onMouseEnter }
- onMouseLeave = { onMouseLeave }
- ref = { containerRef }
- role = { role }
- tabIndex = { tabIndex }>
- {children}
- </div>;
+ ) }
+ id = { id }
+ onClick = { onClick }
+ onKeyDown = { onKeyDown ?? handleKeyDown }
+ onMouseEnter = { onMouseEnter }
+ onMouseLeave = { onMouseLeave }
+ ref = { containerRef }
+ role = { role }
+ tabIndex = { tabIndex }>
+ {children}
+ </div>
+ </FocusOn >;
};
export default ContextMenu;
diff --git a/react/features/base/ui/components/web/ContextMenuItem.tsx b/react/features/base/ui/components/web/ContextMenuItem.tsx
index 51b17e92be..e1b0a087e0 100644
--- a/react/features/base/ui/components/web/ContextMenuItem.tsx
+++ b/react/features/base/ui/components/web/ContextMenuItem.tsx
@@ -85,7 +85,7 @@ export interface IProps {
* If no onClick handler is provided, we assume the context menu item is
* not interactive and no role will be set.
*/
- role?: 'tab' | 'button';
+ role?: 'tab' | 'button' | 'menuitem';
/**
* Whether the item is marked as selected.
diff --git a/react/features/base/ui/components/web/ListItem.tsx b/react/features/base/ui/components/web/ListItem.tsx
index 9b11a41c50..d86b4938fa 100644
--- a/react/features/base/ui/components/web/ListItem.tsx
+++ b/react/features/base/ui/components/web/ListItem.tsx
@@ -18,6 +18,11 @@ interface IProps {
*/
className?: string;
+ /**
+ * The breakout name for aria-label.
+ */
+ defaultName?: string;
+
/**
* Whether or not the actions should be hidden.
*/
@@ -111,7 +116,15 @@ const useStyles = makeStyles()(theme => {
},
highlighted: {
- backgroundColor: theme.palette.ui02
+ backgroundColor: theme.palette.ui02,
+
+ '& .actions': {
+ display: 'flex',
+ position: 'relative',
+ top: 'auto',
+ boxShadow: `-15px 0px 10px -5px ${theme.palette.ui02}`,
+ backgroundColor: theme.palette.ui02
+ }
},
detailsContainer: {
@@ -179,6 +192,7 @@ const useStyles = makeStyles()(theme => {
const ListItem = ({
actions,
className,
+ defaultName,
icon,
id,
hideActions = false,
@@ -229,6 +243,7 @@ const ListItem = ({
return (
<div
+ aria-label = { defaultName }
className = { cx('list-item-container',
classes.container,
isHighlighted && classes.highlighted,
@@ -237,6 +252,7 @@ const ListItem = ({
data-testid = { testId }
id = { id }
onClick = { onClick }
+ role = 'listitem'
{ ...(isMobile
? {
onTouchEnd: _onTouchEnd,
diff --git a/react/features/base/ui/hooks/useContextMenu.web.ts b/react/features/base/ui/hooks/useContextMenu.web.ts
index aa2b8b5224..16840fe2ef 100644
--- a/react/features/base/ui/hooks/useContextMenu.web.ts
+++ b/react/features/base/ui/hooks/useContextMenu.web.ts
@@ -69,7 +69,6 @@ const useContextMenu = <T>(): [(force?: boolean | Object) => void,
const menuLeave = useCallback(() => {
isMouseOverMenu.current = false;
- lowerMenu();
}, [ lowerMenu ]);
return [ lowerMenu, raiseMenu, toggleMenu, menuEnter, menuLeave, raiseContext ];
diff --git a/react/features/participants-pane/components/breakout-rooms/components/web/CollapsibleRoom.tsx b/react/features/participants-pane/components/breakout-rooms/components/web/CollapsibleRoom.tsx
index 8053ec3629..891c1b8b50 100644
--- a/react/features/participants-pane/components/breakout-rooms/components/web/CollapsibleRoom.tsx
+++ b/react/features/participants-pane/components/breakout-rooms/components/web/CollapsibleRoom.tsx
@@ -103,7 +103,8 @@ const useStyles = makeStyles()(theme => {
marginRight: '16px',
display: 'flex',
alignItems: 'center',
- justifyContent: 'center'
+ justifyContent: 'center',
+ border: 'none'
}
};
});
@@ -133,11 +134,15 @@ export const CollapsibleRoom = ({
const overflowDrawer: boolean = useSelector(showOverflowDrawer);
const moderator = useSelector(isLocalParticipantModerator);
- const arrow = (<div className = { styles.arrowContainer }>
+ const arrow = (<button
+ aria-label = { collapsed ? t('breakoutRooms.hideParticipantList', 'Hide participant list')
+ : t('breakoutRooms.showParticipantList', 'Show participant list')
+ }
+ className = { styles.arrowContainer }>
<Icon
size = { 14 }
src = { collapsed ? IconArrowDown : IconArrowUp } />
- </div>);
+ </button>);
const roomName = (<span className = { styles.roomName }>
{`${room.name || t('breakoutRooms.mainRoom')} (${Object.keys(room?.participants
@@ -155,6 +160,8 @@ export const CollapsibleRoom = ({
<ListItem
actions = { children }
className = { cx(styles.container, 'breakout-room-container') }
+ defaultName = { `${room.name || t('breakoutRooms.mainRoom')} (${Object.keys(room?.participants
+ || {}).length})` }
icon = { arrow }
isHighlighted = { isHighlighted }
onClick = { toggleCollapsed }
diff --git a/react/features/participants-pane/components/breakout-rooms/components/web/RoomContextMenu.tsx b/react/features/participants-pane/components/breakout-rooms/components/web/RoomContextMenu.tsx
index 2acea31839..809337d4b6 100644
--- a/react/features/participants-pane/components/breakout-rooms/components/web/RoomContextMenu.tsx
+++ b/react/features/participants-pane/components/breakout-rooms/components/web/RoomContextMenu.tsx
@@ -107,6 +107,7 @@ export const RoomContextMenu = ({
return (
<ContextMenu
+ activateFocusTrap = { true }
entity = { room }
isDrawerOpen = { Boolean(room) }
offsetTarget = { offsetTarget }
diff --git a/react/features/participants-pane/components/breakout-rooms/components/web/RoomList.tsx b/react/features/participants-pane/components/breakout-rooms/components/web/RoomList.tsx
index e82777651e..a96a4ff7fc 100644
--- a/react/features/participants-pane/components/breakout-rooms/components/web/RoomList.tsx
+++ b/react/features/participants-pane/components/breakout-rooms/components/web/RoomList.tsx
@@ -1,4 +1,5 @@
-import React, { useCallback } from 'react';
+import React, { useCallback, useEffect } from 'react';
+import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import { makeStyles } from 'tss-react/mui';
@@ -14,7 +15,6 @@ import {
isInBreakoutRoom
} from '../../../../../breakout-rooms/functions';
import { IRoom } from '../../../../../breakout-rooms/types';
-import { showOverflowDrawer } from '../../../../../toolbox/functions.web';
import { AutoAssignButton } from './AutoAssignButton';
import { CollapsibleRoom } from './CollapsibleRoom';
@@ -42,6 +42,7 @@ const useStyles = makeStyles()(theme => {
export const RoomList = ({ searchString }: IProps) => {
const { classes } = useStyles();
+ const { t } = useTranslation();
const currentRoomId = useSelector(getCurrentRoomId);
const rooms = Object.values(useSelector(getBreakoutRooms, equals))
.filter((room: IRoom) => room.id !== currentRoomId)
@@ -50,7 +51,6 @@ export const RoomList = ({ searchString }: IProps) => {
const isLocalModerator = useSelector(isLocalParticipantModerator);
const showAutoAssign = useSelector(isAutoAssignParticipantsVisible);
const { hideJoinRoomButton } = useSelector(getBreakoutRoomsConfig);
- const overflowDrawer = useSelector(showOverflowDrawer);
const [ lowerMenu, raiseMenu, toggleMenu, menuEnter, menuLeave, raiseContext ] = useContextMenu<IRoom>();
const [ lowerParticipantMenu, raiseParticipantMenu, toggleParticipantMenu,
participantMenuEnter, participantMenuLeave, raiseParticipantContext ] = useContextMenu<{
@@ -58,21 +58,28 @@ export const RoomList = ({ searchString }: IProps) => {
participantName: string;
room: IRoom;
}>();
- const hideMenu = useCallback(() => !overflowDrawer && lowerMenu(), [ overflowDrawer, lowerMenu ]);
const onRaiseMenu = useCallback(room => (target: HTMLElement) => raiseMenu(room, target), [ raiseMenu ]);
+ // close the menu when the room vanishes
+ useEffect(() => {
+ if (raiseContext.entity && !rooms.some(r => r.id === raiseContext.entity?.id)) {
+ lowerMenu();
+ }
+ }, [ raiseContext, rooms, lowerMenu ]);
+
return (
<>
{inBreakoutRoom && <LeaveButton className = { classes.topMargin } />}
{showAutoAssign && <AutoAssignButton className = { classes.topMargin } />}
<div
+ aria-label = { t('breakoutRooms.breakoutList', 'breakout list') }
className = { classes.topMargin }
- id = 'breakout-rooms-list'>
+ id = 'breakout-rooms-list'
+ role = 'list'>
{rooms.map(room => (
<React.Fragment key = { room.id }>
<CollapsibleRoom
- isHighlighted = { raiseContext.entity === room }
- onLeave = { hideMenu }
+ isHighlighted = { true }
onRaiseMenu = { onRaiseMenu(room) }
participantContextEntity = { raiseParticipantContext.entity }
raiseParticipantContextMenu = { raiseParticipantMenu }
diff --git a/react/features/participants-pane/components/web/FooterContextMenu.tsx b/react/features/participants-pane/components/web/FooterContextMenu.tsx
index 7965782a6f..75eaac6806 100644
--- a/react/features/participants-pane/components/web/FooterContextMenu.tsx
+++ b/react/features/participants-pane/components/web/FooterContextMenu.tsx
@@ -29,7 +29,7 @@ import { withPixelLineHeight } from '../../../base/styles/functions.web';
import ContextMenu from '../../../base/ui/components/web/ContextMenu';
import ContextMenuItemGroup from '../../../base/ui/components/web/ContextMenuItemGroup';
import { isInBreakoutRoom } from '../../../breakout-rooms/functions';
-import { openSettingsDialog } from '../../../settings/actions';
+import { openSettingsDialog } from '../../../settings/actions.web';
import { SETTINGS_TABS } from '../../../settings/constants';
import { shouldShowModeratorSettings } from '../../../settings/functions.web';
import MuteEveryonesVideoDialog from '../../../video-menu/components/web/MuteEveryonesVideoDialog';
@@ -133,6 +133,7 @@ export const FooterContextMenu = ({ isOpen, onDrawerClose, onMouseLeave }: IProp
return (
<ContextMenu
+ activateFocusTrap = { true }
className = { classes.contextMenu }
hidden = { !isOpen }
isDrawerOpen = { isOpen }