Skip to content

Commit

Permalink
fix: mic space click [WPB-8580] (#18566)
Browse files Browse the repository at this point in the history
* refactor(KeyboardUtil): handleKeyDown to accept object as a param instead of multiple args

* feat(calling): integrate PropertiesRepository into calling components

* test(fullscreenVideoCall): add PropertiesRepository to test setup

* chore: trigger build
  • Loading branch information
olafsulich authored Jan 9, 2025
1 parent b4e1f39 commit 5050f8e
Show file tree
Hide file tree
Showing 34 changed files with 329 additions and 80 deletions.
4 changes: 2 additions & 2 deletions src/script/auth/page/OAuthPermissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
import * as Icon from 'Components/Icon';
import {AssetRemoteData} from 'src/script/assets/AssetRemoteData';
import {AssetRepository} from 'src/script/assets/AssetRepository';
import {handleEscDown, handleKeyDown} from 'Util/KeyboardUtil';
import {handleEscDown, handleKeyDown, KEY} from 'Util/KeyboardUtil';
import {t} from 'Util/LocalizerUtil';
import {loadDataUrl} from 'Util/util';

Expand Down Expand Up @@ -228,7 +228,7 @@ const OAuthPermissionsComponent = ({
type="button"
onClick={onContinue}
data-uie-name="do-oauth-allow"
onKeyDown={event => handleKeyDown(event, () => onContinue())}
onKeyDown={event => handleKeyDown({event, callback: onContinue, keys: [KEY.ENTER, KEY.SPACE]})}
>
{t('oauth.allow')}
</Button>
Expand Down
1 change: 1 addition & 0 deletions src/script/components/AppContainer/AppContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export const AppContainer: FC<AppProps> = ({config, clientType}) => {

{isDetachedCallingFeatureEnabled() && (
<DetachedCallingCell
propertiesRepository={app.repository.properties}
callingRepository={app.repository.calling}
mediaRepository={app.repository.media}
toggleScreenshare={mainView.calling.callActions.toggleScreenshare}
Expand Down
4 changes: 2 additions & 2 deletions src/script/components/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import {HTMLProps, MouseEvent as ReactMouseEvent, KeyboardEvent as ReactKeyBoardEvent} from 'react';

import {useKoSubscribableChildren} from 'Util/ComponentUtil';
import {handleKeyDown, isKeyboardEvent} from 'Util/KeyboardUtil';
import {handleKeyDown, isKeyboardEvent, KEY} from 'Util/KeyboardUtil';

import {PlaceholderAvatar} from './PlaceholderAvatar';
import {ServiceAvatar} from './ServiceAvatar';
Expand Down Expand Up @@ -97,7 +97,7 @@ const Avatar = ({
const parentNode = event.currentTarget.parentNode;
if (parentNode) {
if (isKeyboardEvent(event)) {
handleKeyDown(event, () => onAvatarClick?.(participant));
handleKeyDown({event, callback: () => onAvatarClick?.(participant), keys: [KEY.ENTER, KEY.SPACE]});
return;
}
onAvatarClick?.(participant);
Expand Down
4 changes: 2 additions & 2 deletions src/script/components/HistoryImport/BackupFileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {TabIndex} from '@wireapp/react-ui-kit/lib/types/enums';
import {Button, ButtonVariant} from '@wireapp/react-ui-kit';

import {CONFIG as HistoryExportConfig} from 'Components/HistoryExport';
import {handleKeyDown} from 'Util/KeyboardUtil';
import {handleKeyDown, KEY} from 'Util/KeyboardUtil';

interface BackupFileUploadProps {
onFileChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
Expand Down Expand Up @@ -64,7 +64,7 @@ const BackupFileUpload = ({
className={cssClassName}
role="button"
tabIndex={TabIndex.FOCUSABLE}
onKeyDown={event => handleKeyDown(event, fileInputClick)}
onKeyDown={event => handleKeyDown({event, callback: fileInputClick, keys: [KEY.ENTER, KEY.SPACE]})}
onClick={() => fileInputRef.current?.click()}
aria-labelledby="do-backup-import"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import React from 'react';
import {TabIndex} from '@wireapp/react-ui-kit/lib/types/enums';

import {CloseIcon} from 'Components/Icon';
import {handleKeyDown} from 'Util/KeyboardUtil';
import {handleKeyDown, KEY} from 'Util/KeyboardUtil';

export interface AssetLoaderProps {
large?: boolean;
Expand All @@ -47,7 +47,7 @@ const AssetLoader: React.FC<AssetLoaderProps> = ({large, loadProgress, onCancel}
tabIndex={TabIndex.FOCUSABLE}
className="media-button"
onClick={onClick}
onKeyDown={event => handleKeyDown(event, () => onClick(event))}
onKeyDown={event => handleKeyDown({event, callback: () => onClick(event), keys: [KEY.ENTER, KEY.SPACE]})}
data-uie-name="status-loading-media"
>
<svg aria-hidden="true" viewBox={viewBox} data-uie-name="asset-loader-svg">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {container} from 'tsyringe';

import {RestrictedFile} from 'Components/asset/RestrictedFile';
import {useKoSubscribableChildren} from 'Util/ComponentUtil';
import {handleKeyDown} from 'Util/KeyboardUtil';
import {handleKeyDown, KEY} from 'Util/KeyboardUtil';
import {t} from 'Util/LocalizerUtil';
import {formatBytes, getFileExtension, trimFileExtension} from 'Util/util';

Expand Down Expand Up @@ -102,7 +102,7 @@ const FileAsset: React.FC<FileAssetProps> = ({
tabIndex={messageFocusedTabIndex}
aria-label={`${t('conversationContextMenuDownload')} ${fileName}.${fileExtension}`}
onClick={onDownloadAsset}
onKeyDown={event => handleKeyDown(event, onDownloadAsset)}
onKeyDown={event => handleKeyDown({event, callback: onDownloadAsset, keys: [KEY.ENTER, KEY.SPACE]})}
>
{isPendingUpload ? (
<div className="asset-placeholder loading-dots" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {CSSObject} from '@emotion/react';
import * as Icon from 'Components/Icon';
import {AssetImage} from 'Components/Image';
import {useKoSubscribableChildren} from 'Util/ComponentUtil';
import {handleKeyDown} from 'Util/KeyboardUtil';
import {handleKeyDown, KEY} from 'Util/KeyboardUtil';
import {t} from 'Util/LocalizerUtil';

import {ContentMessage} from '../../../../../../entity/message/ContentMessage';
Expand Down Expand Up @@ -79,7 +79,9 @@ export const ImageAsset = ({asset, message, onClick}: ImageAssetProps) => {
data-uie-name="go-image-detail"
data-uie-visible={visible && !isObfuscated}
onClick={event => onClick(message, event)}
onKeyDown={event => handleKeyDown(event, onClick.bind(null, message, event))}
onKeyDown={event =>
handleKeyDown({event, callback: onClick.bind(null, message, event), keys: [KEY.ENTER, KEY.SPACE]})
}
tabIndex={0}
role="button"
aria-label={imageAltText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import cx from 'classnames';

import {Image} from 'Components/Image';
import {useKoSubscribableChildren} from 'Util/ComponentUtil';
import {handleKeyDown} from 'Util/KeyboardUtil';
import {handleKeyDown, KEY} from 'Util/KeyboardUtil';
import {t} from 'Util/LocalizerUtil';
import {safeWindowOpen} from 'Util/SanitizationUtil';
import {cleanURL, prependProtocol} from 'Util/UrlUtil';
Expand Down Expand Up @@ -89,7 +89,7 @@ const LinkPreviewAsset: React.FC<LinkPreviewAssetProps> = ({header = false, mess
tabIndex={messageFocusedTabIndex}
className="link-preview-asset"
onClick={onClick}
onKeyDown={e => handleKeyDown(e, () => onClick(e))}
onKeyDown={event => handleKeyDown({event, callback: () => onClick(event), keys: [KEY.ENTER, KEY.SPACE]})}
>
<div className="link-preview-image-container">
{preview && previewImage ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {useEffect, FC, useState, HTMLProps, useRef} from 'react';
import {isKeyDownEvent} from 'src/script/guards/Event';
import {isAuxClickEvent, isClickEvent} from 'src/script/guards/Mouse';
import {getAllFocusableElements, setElementsTabIndex} from 'Util/focusUtil';
import {handleKeyDown} from 'Util/KeyboardUtil';
import {handleKeyDown, KEY} from 'Util/KeyboardUtil';

import {ShowMoreButton} from './ShowMoreButton';

Expand Down Expand Up @@ -88,9 +88,13 @@ const TextMessage: FC<TextMessageRendererProps> = ({
messageDetails: MessageDetails,
) => {
if (isKeyDownEvent(event) && isFocusable) {
handleKeyDown(event, () => {
event.preventDefault();
onMessageClick(event, elementType, messageDetails);
handleKeyDown({
event,
callback: () => {
event.preventDefault();
onMessageClick(event, elementType, messageDetails);
},
keys: [KEY.ENTER, KEY.SPACE],
});
} else if (isClickEvent(event) || isAuxClickEvent(event)) {
event.preventDefault();
Expand Down
6 changes: 5 additions & 1 deletion src/script/components/Modals/DetailViewModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ export const DetailViewModal = ({
};

const handleOnClosePress = (event: KeyboardEvent | ReactKeyboardEvent<HTMLButtonElement>) => {
handleKeyDown(event, onCloseClick);
handleKeyDown({
event,
callback: onCloseClick,
keys: [KEY.ENTER, KEY.SPACE],
});
};

const onReplyClick = async (conversation: Conversation, message: ContentMessage) => {
Expand Down
10 changes: 8 additions & 2 deletions src/script/components/Modals/UserModal/UserModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {EnrichedFields} from 'Components/panel/EnrichedFields';
import {UserActions} from 'Components/panel/UserActions';
import {UserDetails} from 'Components/panel/UserDetails';
import {useKoSubscribableChildren} from 'Util/ComponentUtil';
import {handleKeyDown} from 'Util/KeyboardUtil';
import {handleKeyDown, KEY} from 'Util/KeyboardUtil';
import {replaceLink, t} from 'Util/LocalizerUtil';

import {useUserModalState} from './UserModal.state';
Expand Down Expand Up @@ -197,7 +197,13 @@ const UserModal: React.FC<UserModalProps> = ({
<Icon.CloseIcon
className="modal__header__button"
onClick={hide}
onKeyDown={event => handleKeyDown(event, hide)}
onKeyDown={event =>
handleKeyDown({
event,
callback: hide,
keys: [KEY.ENTER, KEY.SPACE],
})
}
data-uie-name="do-close"
tabIndex={TabIndex.FOCUSABLE}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import cx from 'classnames';
import {Avatar, AVATAR_SIZE} from 'Components/Avatar';
import * as Icon from 'Components/Icon';
import {useKoSubscribableChildren} from 'Util/ComponentUtil';
import {handleKeyDown} from 'Util/KeyboardUtil';
import {handleKeyDown, KEY} from 'Util/KeyboardUtil';

import {User} from '../../../../entity/User';

Expand Down Expand Up @@ -55,7 +55,13 @@ const MentionSuggestionsItemComponent: React.ForwardRefRenderFunction<HTMLDivEle
role="button"
tabIndex={TabIndex.FOCUSABLE}
onClick={onClick}
onKeyDown={e => handleKeyDown(e, () => onClick(e))}
onKeyDown={event =>
handleKeyDown({
event,
callback: () => onClick(event),
keys: [KEY.ENTER, KEY.SPACE],
})
}
onMouseEnter={onMouseEnter}
className={cx('mention-suggestion-list__item', {'mention-suggestion-list__item--highlighted': isSelected})}
data-uie-name="item-mention-suggestion"
Expand Down
10 changes: 8 additions & 2 deletions src/script/components/SelectText/SelectText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import React from 'react';
import {TabIndex} from '@wireapp/react-ui-kit/lib/types/enums';
import cx from 'classnames';

import {handleKeyDown} from 'Util/KeyboardUtil';
import {handleKeyDown, KEY} from 'Util/KeyboardUtil';

export interface SelectTextProps {
text: string;
Expand Down Expand Up @@ -52,7 +52,13 @@ export const SelectText = ({text, className = '', dataUieName = 'select-text'}:
css={{wordBreak: 'break-all'}}
className={cx('select-text', className)}
onClick={onClick}
onKeyDown={event => handleKeyDown(event, () => onClick(event))}
onKeyDown={event =>
handleKeyDown({
event,
callback: () => onClick(event),
keys: [KEY.ENTER, KEY.SPACE],
})
}
>
{text}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {Avatar, AVATAR_SIZE} from 'Components/Avatar';
import {ParticipantItemContent} from 'Components/ParticipantItemContent';
import {listItem, listWrapper} from 'Components/ParticipantItemContent/ParticipantItem.styles';
import {useKoSubscribableChildren} from 'Util/ComponentUtil';
import {handleKeyDown} from 'Util/KeyboardUtil';
import {handleKeyDown, KEY} from 'Util/KeyboardUtil';
import {t} from 'Util/LocalizerUtil';

import {ServiceEntity} from '../../../../integration/ServiceEntity';
Expand All @@ -44,7 +44,13 @@ export const ServiceListItem = ({service, onClick}: ServiceListItemProps) => {
tabIndex={TabIndex.FOCUSABLE}
role="button"
onClick={onServiceClick}
onKeyDown={event => handleKeyDown(event, onServiceClick)}
onKeyDown={event =>
handleKeyDown({
event,
callback: onServiceClick,
keys: [KEY.ENTER, KEY.SPACE],
})
}
data-uie-name="item-service"
data-uie-value={serviceName}
aria-label={t('accessibility.openConversation', {name: serviceName})}
Expand Down
10 changes: 8 additions & 2 deletions src/script/components/TitleBar/TitleBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {User} from 'src/script/entity/User';
import {useAppMainState, ViewType} from 'src/script/page/state';
import {ContentState} from 'src/script/page/useAppState';
import {useKoSubscribableChildren} from 'Util/ComponentUtil';
import {handleKeyDown} from 'Util/KeyboardUtil';
import {handleKeyDown, KEY} from 'Util/KeyboardUtil';
import {t} from 'Util/LocalizerUtil';
import {matchQualifiedIds} from 'Util/QualifiedId';
import {TIME_IN_MILLIS} from 'Util/TimeUtil';
Expand Down Expand Up @@ -252,7 +252,13 @@ export const TitleBar: React.FC<TitleBarProps> = ({
onClick={onClickDetails}
title={peopleTooltip}
aria-label={peopleTooltip}
onKeyDown={event => handleKeyDown(event, onClickDetails)}
onKeyDown={event =>
handleKeyDown({
event,
callback: onClickDetails,
keys: [KEY.ENTER, KEY.SPACE],
})
}
data-placement="bottom"
role="button"
tabIndex={TabIndex.FOCUSABLE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {DeviceVerificationBadges} from 'Components/Badge';
import {LegalHoldDot} from 'Components/LegalHoldDot';
import {useMessageFocusedTabIndex} from 'Components/MessagesList/Message/util';
import {WireIdentity} from 'src/script/E2EIdentity';
import {handleKeyDown} from 'Util/KeyboardUtil';
import {handleKeyDown, KEY} from 'Util/KeyboardUtil';
import {t} from 'Util/LocalizerUtil';
import {splitFingerprint} from 'Util/StringUtil';

Expand Down Expand Up @@ -62,7 +62,13 @@ const DeviceCard = ({click, getDeviceIdentity, device: clientEntity, showIcon =
tabIndex={messageFocusedTabIndex}
className={cx('device-card', {'device-card__no-hover': !clickable})}
onClick={clickOnDevice}
onKeyDown={e => handleKeyDown(e, clickOnDevice)}
onKeyDown={event =>
handleKeyDown({
event,
callback: clickOnDevice,
keys: [KEY.ENTER, KEY.SPACE],
})
}
data-uie-uid={id}
data-uie-name="device-card"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {UserStatusBadges} from 'Components/Badge';
import {CallParticipantsListItemHandRaiseIcon} from 'Components/calling/CallParticipantsListItem/CallParticipantsListItemHandRaiseIcon';
import {Participant} from 'src/script/calling/Participant';
import {useKoSubscribableChildren} from 'Util/ComponentUtil';
import {handleKeyDown} from 'Util/KeyboardUtil';
import {handleKeyDown, KEY} from 'Util/KeyboardUtil';
import {t} from 'Util/LocalizerUtil';
import {setContextMenuPosition} from 'Util/util';

Expand Down Expand Up @@ -68,9 +68,13 @@ export const CallParticipantsListItem = ({
} = useKoSubscribableChildren(user, ['isDirectGuest', 'is_verified', 'name', 'isExternal']);

const handleContextKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
handleKeyDown(event, () => {
const newEvent = setContextMenuPosition(event);
onContextMenu?.(newEvent as unknown as React.MouseEvent<HTMLDivElement>);
handleKeyDown({
event,
callback: () => {
const newEvent = setContextMenuPosition(event);
onContextMenu?.(newEvent as unknown as React.MouseEvent<HTMLDivElement>);
},
keys: [KEY.ENTER, KEY.SPACE],
});
};

Expand Down
4 changes: 4 additions & 0 deletions src/script/components/calling/CallingOverlayContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import React, {Fragment, useEffect} from 'react';
import {container} from 'tsyringe';

import {useCallAlertState} from 'Components/calling/useCallAlertState';
import {PropertiesRepository} from 'src/script/properties/PropertiesRepository';
import {useKoSubscribableChildren} from 'Util/ComponentUtil';

import {ChooseScreen} from './ChooseScreen';
Expand All @@ -37,13 +38,15 @@ import {MediaRepository} from '../../media/MediaRepository';
import {CallViewTab} from '../../view_model/CallingViewModel';

export interface CallingContainerProps {
readonly propertiesRepository: PropertiesRepository;
readonly callingRepository: CallingRepository;
readonly mediaRepository: MediaRepository;
readonly callState?: CallState;
readonly toggleScreenshare: (call: Call, desktopScreenShareMenu: DesktopScreenShareMenu) => void;
}

const CallingContainer: React.FC<CallingContainerProps> = ({
propertiesRepository,
mediaRepository,
callingRepository,
callState = container.resolve(CallState),
Expand Down Expand Up @@ -150,6 +153,7 @@ const CallingContainer: React.FC<CallingContainerProps> = ({
conversation={conversation}
canShareScreen={callingRepository.supportsScreenSharing}
maximizedParticipant={maximizedParticipant}
propertiesRepository={propertiesRepository}
callingRepository={callingRepository}
mediaDevicesHandler={mediaDevicesHandler}
isMuted={isMuted}
Expand Down
Loading

0 comments on commit 5050f8e

Please sign in to comment.