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(participants-pane): close context menus on outside click (#17604)

Дамян Минков7263d2f7a5a4
diff --git a/react/features/base/ui/components/web/ContextMenu.tsx b/react/features/base/ui/components/web/ContextMenu.tsx
index b351463fb1..0501a4db05 100644
--- a/react/features/base/ui/components/web/ContextMenu.tsx
+++ b/react/features/base/ui/components/web/ContextMenu.tsx
@@ -97,6 +97,13 @@ interface IProps {
*/
onClick?: (e?: React.MouseEvent) => void;
+ /**
+ * Callback invoked when a click occurs outside the menu (non-drawer path only).
+ * Prefer this over onDrawerClose for outside-click handling to avoid conflating
+ * the drawer-close and the click-outside concerns.
+ */
+ onClickOutside?: () => void;
+
/**
* Callback for drawer close.
*/
@@ -181,6 +188,7 @@ const ContextMenu = ({
offsetTarget,
onClick,
onKeyDown,
+ onClickOutside,
onDrawerClose,
onMouseEnter,
onMouseLeave,
@@ -358,8 +366,8 @@ const ContextMenu = ({
}, [ containerRef ]);
const removeFocus = useCallback(() => {
- onDrawerClose?.();
- }, [ onMouseLeave ]);
+ (onClickOutside ?? onDrawerClose)?.();
+ }, [ onClickOutside, onDrawerClose ]);
if (_overflowDrawer && inDrawer) {
return (<div
@@ -387,8 +395,10 @@ const ContextMenu = ({
// to prevent UI stutter on dialog appearance. It seems the focus guards generated annoy
// our DialogPortal positioning calculations.
enabled = { activateFocusTrap && !isHidden }
+ noIsolation = { true }
onClickOutside = { removeFocus }
- onEscapeKey = { removeFocus }>
+ onEscapeKey = { removeFocus }
+ scrollLock = { false }>
<div
{ ...aria }
aria-label = { accessibilityLabel }
diff --git a/react/features/participants-pane/components/breakout-rooms/components/web/RoomParticipantContextMenu.tsx b/react/features/participants-pane/components/breakout-rooms/components/web/RoomParticipantContextMenu.tsx
index 4a2d971b51..a8491d2484 100644
--- a/react/features/participants-pane/components/breakout-rooms/components/web/RoomParticipantContextMenu.tsx
+++ b/react/features/participants-pane/components/breakout-rooms/components/web/RoomParticipantContextMenu.tsx
@@ -108,10 +108,12 @@ export const RoomParticipantContextMenu = ({
return isLocalModerator ? (
<ContextMenu
+ activateFocusTrap = { true }
entity = { entity }
isDrawerOpen = { Boolean(entity) }
offsetTarget = { offsetTarget }
onClick = { lowerMenu }
+ onClickOutside = { lowerMenu }
onDrawerClose = { onSelect }
onMouseEnter = { onEnter }
onMouseLeave = { onLeave }>
diff --git a/react/features/video-menu/components/web/FakeParticipantContextMenu.tsx b/react/features/video-menu/components/web/FakeParticipantContextMenu.tsx
index 91a962fd6e..37ce9bf174 100644
--- a/react/features/video-menu/components/web/FakeParticipantContextMenu.tsx
+++ b/react/features/video-menu/components/web/FakeParticipantContextMenu.tsx
@@ -140,6 +140,7 @@ const FakeParticipantContextMenu = ({
return (
<ContextMenu
+ activateFocusTrap = { !thumbnailMenu }
className = { className }
entity = { participant }
hidden = { thumbnailMenu ? false : undefined }
@@ -147,6 +148,7 @@ const FakeParticipantContextMenu = ({
isDrawerOpen = { Boolean(drawerParticipant) }
offsetTarget = { offsetTarget }
onClick = { onSelect }
+ onClickOutside = { thumbnailMenu ? undefined : clickHandler }
onDrawerClose = { thumbnailMenu ? onSelect : closeDrawer }
onMouseEnter = { onEnter }
onMouseLeave = { onLeave }>
diff --git a/react/features/video-menu/components/web/ParticipantContextMenu.tsx b/react/features/video-menu/components/web/ParticipantContextMenu.tsx
index b1d7e22ab5..c27091272c 100644
--- a/react/features/video-menu/components/web/ParticipantContextMenu.tsx
+++ b/react/features/video-menu/components/web/ParticipantContextMenu.tsx
@@ -193,6 +193,10 @@ const ParticipantContextMenu = ({
onSelect(true);
}, [ onSelect ]);
+ const onClickOutside = useCallback(() => {
+ onSelect(true);
+ }, [ onSelect ]);
+
const isClickedFromParticipantPane = useMemo(
() => !_overflowDrawer && !thumbnailMenu,
[ _overflowDrawer, thumbnailMenu ]);
@@ -346,6 +350,7 @@ const ParticipantContextMenu = ({
return (
<ContextMenu
+ activateFocusTrap = { !thumbnailMenu }
className = { className }
entity = { participant }
hidden = { thumbnailMenu ? false : undefined }
@@ -353,6 +358,7 @@ const ParticipantContextMenu = ({
isDrawerOpen = { Boolean(drawerParticipant) }
offsetTarget = { offsetTarget }
onClick = { onSelect }
+ onClickOutside = { thumbnailMenu ? undefined : onClickOutside }
onDrawerClose = { thumbnailMenu ? onSelect : closeDrawer }
onMouseEnter = { onEnter }
onMouseLeave = { onLeave }>