Skip to content

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

fix(a11y): make web controls keyboard accessible (#18112)

Navyaff04fd09c145
diff --git a/react/features/base/ui/functions.web.ts b/react/features/base/ui/functions.web.ts
index 0d7f2b2f24..5c0a7c50ec 100644
--- a/react/features/base/ui/functions.web.ts
+++ b/react/features/base/ui/functions.web.ts
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { Theme, adaptV4Theme, createTheme } from '@mui/material/styles';
+import type { KeyboardEvent } from 'react';
import { ITypography, IPalette as Palette1 } from '../ui/types';
@@ -109,6 +110,23 @@ export function operatesWithEnterKey(element: Element): boolean {
return false;
}
+/**
+ * Creates a keydown handler that calls the given callback when Enter or Space is pressed. Meant to be used together
+ * with role="button" and tabIndex={0} on clickable elements that are not native buttons.
+ *
+ * @param {Function} callback - The function to call, with the keyboard event, when the element is activated using
+ * the keyboard.
+ * @returns {Function}
+ */
+export function onActivationKey(callback: (e: KeyboardEvent) => void) {
+ return (e: KeyboardEvent) => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ e.preventDefault();
+ callback(e);
+ }
+ };
+}
+
/**
* Returns a common spacing from the bottom of the page for floating elements over the video space.
*
diff --git a/react/features/calendar-sync/components/CalendarList.web.tsx b/react/features/calendar-sync/components/CalendarList.web.tsx
index 62143b0b47..f6b4b219ed 100644
--- a/react/features/calendar-sync/components/CalendarList.web.tsx
+++ b/react/features/calendar-sync/components/CalendarList.web.tsx
@@ -10,6 +10,7 @@ import Icon from '../../base/icons/components/Icon';
import { IconCalendar } from '../../base/icons/svg';
import AbstractPage from '../../base/react/components/AbstractPage';
import Spinner from '../../base/ui/components/web/Spinner';
+import { onActivationKey } from '../../base/ui/functions.web';
import { openSettingsDialog } from '../../settings/actions.web';
import { SETTINGS_TABS } from '../../settings/constants';
import { refreshCalendar, signIn } from '../actions.web';
@@ -65,7 +66,6 @@ class CalendarList extends AbstractPage<IProps> {
this._getRenderListEmptyComponent
= this._getRenderListEmptyComponent.bind(this);
this._onOpenSettings = this._onOpenSettings.bind(this);
- this._onKeyPressOpenSettings = this._onKeyPressOpenSettings.bind(this);
this._onRefreshEvents = this._onRefreshEvents.bind(this);
this._onSignIn = this._onSignIn.bind(this);
}
@@ -139,14 +139,20 @@ class CalendarList extends AbstractPage<IProps> {
{ showSettingsButton
&& <div
className = 'button'
- onClick = { this._onOpenSettings }>
+ onClick = { this._onOpenSettings }
+ onKeyDown = { onActivationKey(this._onOpenSettings) }
+ role = 'button'
+ tabIndex = { 0 }>
{ t('calendarSync.permissionButton') }
</div>
}
{ showRefreshButton
&& <div
className = 'button'
- onClick = { this._onRefreshEvents }>
+ onClick = { this._onRefreshEvents }
+ onKeyDown = { onActivationKey(this._onRefreshEvents) }
+ role = 'button'
+ tabIndex = { 0 }>
{ t('calendarSync.refresh') }
</div>
}
@@ -180,7 +186,10 @@ class CalendarList extends AbstractPage<IProps> {
</p>
<div
className = 'button'
- onClick = { this._onRefreshEvents }>
+ onClick = { this._onRefreshEvents }
+ onKeyDown = { onActivationKey(this._onRefreshEvents) }
+ role = 'button'
+ tabIndex = { 0 }>
{ t('calendarSync.refresh') }
</div>
</div>
@@ -209,7 +218,7 @@ class CalendarList extends AbstractPage<IProps> {
<div
className = 'meetings-list-empty-button'
onClick = { this._onOpenSettings }
- onKeyPress = { this._onKeyPressOpenSettings }
+ onKeyDown = { onActivationKey(this._onOpenSettings) }
role = 'button'
tabIndex = { 0 }>
<Icon
@@ -233,21 +242,6 @@ class CalendarList extends AbstractPage<IProps> {
this.props.dispatch(openSettingsDialog(SETTINGS_TABS.CALENDAR));
}
- /**
- * KeyPress handler for accessibility.
- *
- * @param {Object} e - The key event to handle.
- *
- * @returns {void}
- */
- _onKeyPressOpenSettings(e: React.KeyboardEvent) {
- if (e.key === ' ' || e.key === 'Enter') {
- e.preventDefault();
- this._onOpenSettings();
- }
- }
-
-
/**
* Gets an updated list of calendar events.
*
diff --git a/react/features/calendar-sync/components/MicrosoftSignInButton.web.tsx b/react/features/calendar-sync/components/MicrosoftSignInButton.web.tsx
index 911fb56e55..370208c872 100644
--- a/react/features/calendar-sync/components/MicrosoftSignInButton.web.tsx
+++ b/react/features/calendar-sync/components/MicrosoftSignInButton.web.tsx
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
import { WithTranslation } from 'react-i18next';
import { translate } from '../../base/i18n/functions';
+import { onActivationKey } from '../../base/ui/functions.web';
/**
* The type of the React {@code Component} props of
@@ -36,7 +37,10 @@ class MicrosoftSignInButton extends Component<IProps> {
return (
<div
className = 'microsoft-sign-in'
- onClick = { this.props.onClick }>
+ onClick = { this.props.onClick }
+ onKeyDown = { onActivationKey(() => this.props.onClick()) }
+ role = 'button'
+ tabIndex = { 0 }>
<img
alt = { this.props.t('welcomepage.logo.microsoftLogo') }
className = 'microsoft-logo'
diff --git a/react/features/google-api/components/GoogleSignInButton.web.tsx b/react/features/google-api/components/GoogleSignInButton.web.tsx
index d997d74fa9..667483e2d0 100644
--- a/react/features/google-api/components/GoogleSignInButton.web.tsx
+++ b/react/features/google-api/components/GoogleSignInButton.web.tsx
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
import { WithTranslation } from 'react-i18next';
import { translate } from '../../base/i18n/functions';
+import { onActivationKey } from '../../base/ui/functions.web';
interface IProps extends WithTranslation {
@@ -41,7 +42,10 @@ class GoogleSignInButton extends Component<IProps> {
return (
<div
className = 'google-sign-in'
- onClick = { this.props.onClick }>
+ onClick = { this.props.onClick }
+ onKeyDown = { onActivationKey(() => this.props.onClick()) }
+ role = 'button'
+ tabIndex = { 0 }>
<img
alt = { t('welcomepage.logo.googleLogo') }
className = 'google-logo'
diff --git a/react/features/participants-pane/components/breakout-rooms/components/web/RenameButton.tsx b/react/features/participants-pane/components/breakout-rooms/components/web/RenameButton.tsx
index 51488177d5..7fb8ee9f86 100644
--- a/react/features/participants-pane/components/breakout-rooms/components/web/RenameButton.tsx
+++ b/react/features/participants-pane/components/breakout-rooms/components/web/RenameButton.tsx
@@ -1,9 +1,11 @@
import React, { useCallback } from 'react';
+import { useTranslation } from 'react-i18next';
import { useDispatch } from 'react-redux';
import { makeStyles } from 'tss-react/mui';
import { openDialog } from '../../../../../base/dialog/actions';
import { IconEdit } from '../../../../../base/icons/svg';
+import { onActivationKey } from '../../../../../base/ui/functions.web';
import BreakoutRoomNamePrompt from './BreakoutRoomNamePrompt';
@@ -32,6 +34,7 @@ interface IProps {
*/
export default function RenameButton({ breakoutRoomJid, name }: IProps) {
const dispatch = useDispatch();
+ const { t } = useTranslation();
const { classes, cx } = useStyles();
const onRename = useCallback(() => {
dispatch(openDialog('BreakoutRoomNamePrompt', BreakoutRoomNamePrompt, {
@@ -42,8 +45,12 @@ export default function RenameButton({ breakoutRoomJid, name }: IProps) {
return (
<span
+ aria-label = { t('breakoutRooms.actions.rename') }
className = { cx('jitsi-icon jitsi-icon-default', classes.container) }
- onClick = { onRename }>
+ onClick = { onRename }
+ onKeyDown = { onActivationKey(onRename) }
+ role = 'button'
+ tabIndex = { 0 }>
<IconEdit
height = { 16 }
key = { 1 }
diff --git a/react/features/participants-pane/components/web/CurrentVisitorsList.tsx b/react/features/participants-pane/components/web/CurrentVisitorsList.tsx
index dc9aa73166..418a39c6a3 100644
--- a/react/features/participants-pane/components/web/CurrentVisitorsList.tsx
+++ b/react/features/participants-pane/components/web/CurrentVisitorsList.tsx
@@ -9,6 +9,7 @@ import { makeStyles } from 'tss-react/mui';
import { IReduxState } from '../../../app/types';
import Icon from '../../../base/icons/components/Icon';
import { IconArrowDown, IconArrowUp } from '../../../base/icons/svg';
+import { onActivationKey } from '../../../base/ui/functions.web';
import { normalizeAccents } from '../../../base/util/strings.web';
import { subscribeVisitorsList } from '../../../visitors/actions';
import {
@@ -142,8 +143,12 @@ export default function CurrentVisitorsList({ searchString }: IProps) {
return (
<div className = { classes.container }>
<div
+ aria-expanded = { !collapsed }
className = { classes.heading }
- onClick = { toggleCollapsed }>
+ onClick = { toggleCollapsed }
+ onKeyDown = { onActivationKey(toggleCollapsed) }
+ role = 'button'
+ tabIndex = { 0 }>
<span>{ t('participantsPane.headings.visitorsList', { count: visitorsCount }) }</span>
<span className = { classes.arrowContainer }>
<Icon
diff --git a/react/features/participants-pane/components/web/LobbyParticipants.tsx b/react/features/participants-pane/components/web/LobbyParticipants.tsx
index ed2bd6c582..a308ea0f28 100644
--- a/react/features/participants-pane/components/web/LobbyParticipants.tsx
+++ b/react/features/participants-pane/components/web/LobbyParticipants.tsx
@@ -6,6 +6,7 @@ import { makeStyles } from 'tss-react/mui';
import Avatar from '../../../base/avatar/components/Avatar';
import Icon from '../../../base/icons/components/Icon';
import { IconCheck, IconCloseLarge } from '../../../base/icons/svg';
+import { onActivationKey } from '../../../base/ui/functions.web';
import { admitMultiple } from '../../../lobby/actions.web';
import { getKnockingParticipants, getLobbyEnabled } from '../../../lobby/functions';
import Drawer from '../../../toolbox/components/web/Drawer';
@@ -38,6 +39,24 @@ const useStyles = makeStyles()(theme => {
background: theme.palette.participantActionButton
}
},
+ drawerButton: {
+ alignItems: 'center',
+ appearance: 'none',
+ background: 'none',
+ border: 0,
+ color: theme.palette.participantCounterText,
+ display: 'flex',
+ fontFamily: 'inherit',
+ padding: '12px 16px',
+ textAlign: 'start',
+ width: '100%',
+ ...theme.typography.bodyShortRegularLarge,
+
+ '&:hover': {
+ cursor: 'pointer',
+ background: theme.palette.participantActionButton
+ }
+ },
icon: {
marginRight: 16
},
@@ -90,7 +109,10 @@ export default function LobbyParticipants() {
participants.length > 1
&& <div
className = { classes.link }
- onClick = { admitAll }>{t('participantsPane.actions.admitAll')}</div>
+ onClick = { admitAll }
+ onKeyDown = { onActivationKey(admitAll) }
+ role = 'button'
+ tabIndex = { 0 }>{t('participantsPane.actions.admitAll')}</div>
}
</div>
<LobbyParticipantItems
@@ -109,23 +131,29 @@ export default function LobbyParticipants() {
size = { 20 } />
<span>{ drawerParticipant?.displayName }</span>
</li>
- <li
- className = { classes.drawerItem }
- onClick = { admit }>
- <Icon
- className = { classes.icon }
- size = { 20 }
- src = { IconCheck } />
- <span>{ t('participantsPane.actions.admit') }</span>
+ <li>
+ <button
+ className = { classes.drawerButton }
+ onClick = { admit }
+ type = 'button'>
+ <Icon
+ className = { classes.icon }
+ size = { 20 }
+ src = { IconCheck } />
+ <span>{ t('participantsPane.actions.admit') }</span>
+ </button>
</li>
- <li
- className = { classes.drawerItem }
- onClick = { reject }>
- <Icon
- className = { classes.icon }
- size = { 20 }
- src = { IconCloseLarge } />
- <span>{ t('participantsPane.actions.reject')}</span>
+ <li>
+ <button
+ className = { classes.drawerButton }
+ onClick = { reject }
+ type = 'button'>
+ <Icon
+ className = { classes.icon }
+ size = { 20 }
+ src = { IconCloseLarge } />
+ <span>{ t('participantsPane.actions.reject')}</span>
+ </button>
</li>
</ul>
</Drawer>
diff --git a/react/features/participants-pane/components/web/VisitorsList.tsx b/react/features/participants-pane/components/web/VisitorsList.tsx
index 5af865e8d6..24e5f7ca72 100644
--- a/react/features/participants-pane/components/web/VisitorsList.tsx
+++ b/react/features/participants-pane/components/web/VisitorsList.tsx
@@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
import { makeStyles } from 'tss-react/mui';
+import { onActivationKey } from '../../../base/ui/functions.web';
import { admitMultiple, goLive } from '../../../visitors/actions';
import {
getPromotionRequests,
@@ -112,13 +113,19 @@ export default function VisitorsList() {
requests.length > 1 && !showVisitorsInQueue // Go live button is with higher priority
&& <div
className = { classes.link }
- onClick = { admitAll }>{ t('participantsPane.actions.admitAll') }</div>
+ onClick = { admitAll }
+ onKeyDown = { onActivationKey(admitAll) }
+ role = 'button'
+ tabIndex = { 0 }>{ t('participantsPane.actions.admitAll') }</div>
}
{
showVisitorsInQueue
&& <div
className = { classes.link }
- onClick = { goLiveCb }>{ t('participantsPane.actions.goLive') }</div>
+ onClick = { goLiveCb }
+ onKeyDown = { onActivationKey(goLiveCb) }
+ role = 'button'
+ tabIndex = { 0 }>{ t('participantsPane.actions.goLive') }</div>
}
</div>
{ requests.length > 0
diff --git a/react/features/prejoin/components/web/dialogs/DialInDialog.tsx b/react/features/prejoin/components/web/dialogs/DialInDialog.tsx
index 7c5f283173..e7521fe4f2 100644
--- a/react/features/prejoin/components/web/dialogs/DialInDialog.tsx
+++ b/react/features/prejoin/components/web/dialogs/DialInDialog.tsx
@@ -6,6 +6,7 @@ import { translate } from '../../../../base/i18n/functions';
import Icon from '../../../../base/icons/components/Icon';
import { IconArrowLeft } from '../../../../base/icons/svg';
import Button from '../../../../base/ui/components/web/Button';
+import { onActivationKey } from '../../../../base/ui/functions.web';
import { getCountryCodeFromPhone } from '../../../utils';
import Label from '../Label';
@@ -141,7 +142,10 @@ function DialinDialog(props: IProps) {
<div>
<span
className = 'prejoin-dialog-dialin-link'
- onClick = { onSmallTextClick }>
+ onClick = { onSmallTextClick }
+ onKeyDown = { onActivationKey(() => onSmallTextClick()) }
+ role = 'button'
+ tabIndex = { 0 }>
{t('prejoin.viewAllNumbers')}
</span>
</div>