From ce38019556a0d91e342c5fb2c8e0004cbd6add32 Mon Sep 17 00:00:00 2001 From: V-Gira Date: Wed, 17 Jan 2024 12:21:43 +0100 Subject: [PATCH] runfix: address keyboard navigation issues in call ui (WPB-6075) --- .../calling/FullscreenVideoCall.tsx | 47 ++++++------------- src/script/components/calling/Pagination.tsx | 3 ++ 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/src/script/components/calling/FullscreenVideoCall.tsx b/src/script/components/calling/FullscreenVideoCall.tsx index 1d88260cbf4..d9bcdd270ad 100644 --- a/src/script/components/calling/FullscreenVideoCall.tsx +++ b/src/script/components/calling/FullscreenVideoCall.tsx @@ -31,7 +31,7 @@ import {ConversationClassifiedBar} from 'Components/input/ClassifiedBar'; import {isMediaDevice} from 'src/script/guards/MediaDevice'; import {MediaDeviceType} from 'src/script/media/MediaDeviceType'; import {useKoSubscribableChildren} from 'Util/ComponentUtil'; -import {isEnterKey, KEY} from 'Util/KeyboardUtil'; +import {handleKeyDown, isEscapeKey} from 'Util/KeyboardUtil'; import {t} from 'Util/LocalizerUtil'; import {preventFocusOutside} from 'Util/util'; @@ -206,7 +206,6 @@ const FullscreenVideoCall: React.FC = ({ setSelectedAudioOptions([microphone, speaker]); switchMicrophoneInput(microphone.id); switchSpeakerOutput(speaker.id); - setAudioOptionsOpen(false); }; const videoOptions = [ @@ -239,7 +238,6 @@ const FullscreenVideoCall: React.FC = ({ const camera = videoOptions[0].options.find(item => item.value === selectedOption) ?? selectedVideoOptions[0]; setSelectedVideoOptions([camera]); switchCameraInput(camera.id); - setVideoOptionsOpen(false); }; const unreadMessagesCount = useAppState(state => state.unreadMessagesCount); @@ -249,17 +247,6 @@ const FullscreenVideoCall: React.FC = ({ const totalPages = callPages.length; - const isSpaceOrEnterKey = (event: React.KeyboardEvent) => - [KEY.ENTER, KEY.SPACE].includes(event.key); - - const handleToggleCameraKeydown = (event: React.KeyboardEvent) => { - if (isSpaceOrEnterKey(event)) { - toggleCamera(call); - } - - return true; - }; - // To be changed when design chooses a breakpoint, the conditional can be integrated to the ui-kit directly const horizontalSmBreakpoint = useMatchMedia('max-width: 680px'); const horizontalXsBreakpoint = useMatchMedia('max-width: 500px'); @@ -267,9 +254,7 @@ const FullscreenVideoCall: React.FC = ({ useEffect(() => { const onKeyDown = (event: KeyboardEvent): void => { - if (!isEnterKey(event)) { - event.preventDefault(); - } + event.preventDefault(); preventFocusOutside(event, 'video-calling'); }; document.addEventListener('keydown', onKeyDown); @@ -361,6 +346,7 @@ const FullscreenVideoCall: React.FC = ({