From 7065ef08856324cbac3f80ca4c32b08e86fbfcc3 Mon Sep 17 00:00:00 2001
From: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com>
Date: Wed, 24 Jan 2024 09:33:20 -0800
Subject: [PATCH] Restore call reactions click outside to dismiss

---
 ts/components/CallScreen.tsx | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/ts/components/CallScreen.tsx b/ts/components/CallScreen.tsx
index 21a848994f4..759526549ea 100644
--- a/ts/components/CallScreen.tsx
+++ b/ts/components/CallScreen.tsx
@@ -71,6 +71,7 @@ import {
   PersistentCallingToast,
   useCallingToasts,
 } from './CallingToast';
+import { handleOutsideClick } from '../util/handleOutsideClick';
 import { Spinner } from './Spinner';
 import type { Props as ReactionPickerProps } from './conversation/ReactionPicker';
 import type { SmartReactionPicker } from '../state/smart/ReactionPicker';
@@ -328,6 +329,22 @@ export function CallScreen({
     };
   }, [toggleAudio, toggleVideo]);
 
+  useEffect(() => {
+    if (!showReactionPicker) {
+      return noop;
+    }
+    return handleOutsideClick(
+      () => {
+        setShowReactionPicker(false);
+        return true;
+      },
+      {
+        containerElements: [reactButtonRef, reactionPickerContainerRef],
+        name: 'CallScreen.reactionPicker',
+      }
+    );
+  }, [showReactionPicker]);
+
   useScreenSharingStoppedToast({ activeCall, i18n });
   useViewModeChangedToast({ activeCall, i18n });