Add focus trap to CallingLobby
This commit is contained in:
parent
cbae7f8ee9
commit
b35d330c0a
2 changed files with 79 additions and 70 deletions
|
@ -2,6 +2,7 @@
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import FocusTrap from 'focus-trap-react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import type {
|
import type {
|
||||||
SetLocalAudioType,
|
SetLocalAudioType,
|
||||||
|
@ -204,83 +205,85 @@ export const CallingLobby = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="module-calling__container">
|
<FocusTrap>
|
||||||
{shouldShowLocalVideo ? (
|
<div className="module-calling__container">
|
||||||
<video
|
{shouldShowLocalVideo ? (
|
||||||
className="module-CallingLobby__local-preview module-CallingLobby__local-preview--camera-is-on"
|
<video
|
||||||
ref={localVideoRef}
|
className="module-CallingLobby__local-preview module-CallingLobby__local-preview--camera-is-on"
|
||||||
autoPlay
|
ref={localVideoRef}
|
||||||
/>
|
autoPlay
|
||||||
) : (
|
/>
|
||||||
<CallBackgroundBlur
|
) : (
|
||||||
className="module-CallingLobby__local-preview module-CallingLobby__local-preview--camera-is-off"
|
<CallBackgroundBlur
|
||||||
avatarPath={me.avatarPath}
|
className="module-CallingLobby__local-preview module-CallingLobby__local-preview--camera-is-off"
|
||||||
color={me.color}
|
avatarPath={me.avatarPath}
|
||||||
/>
|
color={me.color}
|
||||||
)}
|
/>
|
||||||
|
|
||||||
<CallingHeader
|
|
||||||
i18n={i18n}
|
|
||||||
isGroupCall={isGroupCall}
|
|
||||||
participantCount={peekedParticipants.length}
|
|
||||||
showParticipantsList={showParticipantsList}
|
|
||||||
toggleParticipants={toggleParticipants}
|
|
||||||
toggleSettings={toggleSettings}
|
|
||||||
onCancel={onCallCanceled}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<CallingPreCallInfo
|
|
||||||
conversation={conversation}
|
|
||||||
groupMembers={groupMembers}
|
|
||||||
i18n={i18n}
|
|
||||||
isCallFull={isCallFull}
|
|
||||||
me={me}
|
|
||||||
peekedParticipants={peekedParticipants}
|
|
||||||
ringMode={preCallInfoRingMode}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div
|
|
||||||
className={classNames(
|
|
||||||
'module-CallingLobby__camera-is-off',
|
|
||||||
`module-CallingLobby__camera-is-off--${
|
|
||||||
shouldShowLocalVideo ? 'invisible' : 'visible'
|
|
||||||
}`
|
|
||||||
)}
|
)}
|
||||||
>
|
|
||||||
{i18n('calling__your-video-is-off')}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="module-calling__buttons module-calling__buttons--inline">
|
<CallingHeader
|
||||||
<CallingButton
|
|
||||||
buttonType={videoButtonType}
|
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
onClick={toggleVideo}
|
isGroupCall={isGroupCall}
|
||||||
tooltipDirection={TooltipPlacement.Top}
|
participantCount={peekedParticipants.length}
|
||||||
|
showParticipantsList={showParticipantsList}
|
||||||
|
toggleParticipants={toggleParticipants}
|
||||||
|
toggleSettings={toggleSettings}
|
||||||
|
onCancel={onCallCanceled}
|
||||||
/>
|
/>
|
||||||
<CallingButton
|
|
||||||
buttonType={audioButtonType}
|
<CallingPreCallInfo
|
||||||
|
conversation={conversation}
|
||||||
|
groupMembers={groupMembers}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
onClick={toggleAudio}
|
isCallFull={isCallFull}
|
||||||
tooltipDirection={TooltipPlacement.Top}
|
me={me}
|
||||||
|
peekedParticipants={peekedParticipants}
|
||||||
|
ringMode={preCallInfoRingMode}
|
||||||
/>
|
/>
|
||||||
<CallingButton
|
|
||||||
buttonType={ringButtonType}
|
<div
|
||||||
|
className={classNames(
|
||||||
|
'module-CallingLobby__camera-is-off',
|
||||||
|
`module-CallingLobby__camera-is-off--${
|
||||||
|
shouldShowLocalVideo ? 'invisible' : 'visible'
|
||||||
|
}`
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{i18n('calling__your-video-is-off')}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="module-calling__buttons module-calling__buttons--inline">
|
||||||
|
<CallingButton
|
||||||
|
buttonType={videoButtonType}
|
||||||
|
i18n={i18n}
|
||||||
|
onClick={toggleVideo}
|
||||||
|
tooltipDirection={TooltipPlacement.Top}
|
||||||
|
/>
|
||||||
|
<CallingButton
|
||||||
|
buttonType={audioButtonType}
|
||||||
|
i18n={i18n}
|
||||||
|
onClick={toggleAudio}
|
||||||
|
tooltipDirection={TooltipPlacement.Top}
|
||||||
|
/>
|
||||||
|
<CallingButton
|
||||||
|
buttonType={ringButtonType}
|
||||||
|
i18n={i18n}
|
||||||
|
isVisible={isRingButtonVisible}
|
||||||
|
onClick={toggleOutgoingRing}
|
||||||
|
tooltipDirection={TooltipPlacement.Top}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<CallingLobbyJoinButton
|
||||||
|
disabled={!canJoin}
|
||||||
i18n={i18n}
|
i18n={i18n}
|
||||||
isVisible={isRingButtonVisible}
|
onClick={() => {
|
||||||
onClick={toggleOutgoingRing}
|
setIsCallConnecting(true);
|
||||||
tooltipDirection={TooltipPlacement.Top}
|
onJoinCall();
|
||||||
|
}}
|
||||||
|
variant={callingLobbyJoinButtonVariant}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</FocusTrap>
|
||||||
<CallingLobbyJoinButton
|
|
||||||
disabled={!canJoin}
|
|
||||||
i18n={i18n}
|
|
||||||
onClick={() => {
|
|
||||||
setIsCallConnecting(true);
|
|
||||||
onJoinCall();
|
|
||||||
}}
|
|
||||||
variant={callingLobbyJoinButtonVariant}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,6 +34,12 @@ const TooltipEventWrapper = React.forwardRef<
|
||||||
onHoverChanged(false);
|
onHoverChanged(false);
|
||||||
}, [onHoverChanged]);
|
}, [onHoverChanged]);
|
||||||
|
|
||||||
|
const onFocus = React.useCallback(() => {
|
||||||
|
if (window.getInteractionMode() === 'keyboard') {
|
||||||
|
on();
|
||||||
|
}
|
||||||
|
}, [on]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const wrapperEl = wrapperRef.current;
|
const wrapperEl = wrapperRef.current;
|
||||||
|
|
||||||
|
@ -52,7 +58,7 @@ const TooltipEventWrapper = React.forwardRef<
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
onFocus={on}
|
onFocus={onFocus}
|
||||||
onBlur={off}
|
onBlur={off}
|
||||||
ref={refMerger<HTMLSpanElement>(ref, wrapperRef)}
|
ref={refMerger<HTMLSpanElement>(ref, wrapperRef)}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue