From 016866c62bfaff900dc62bc557862b0930e255f0 Mon Sep 17 00:00:00 2001
From: ubermanu <e.vodor@gmail.com>
Date: Tue, 16 Mar 2021 22:12:27 +0100
Subject: [PATCH] close the emoji drawer if clicked outside

---
 src/plugins/sib-reactions.js | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/plugins/sib-reactions.js b/src/plugins/sib-reactions.js
index eb9c9a4..80d73ce 100644
--- a/src/plugins/sib-reactions.js
+++ b/src/plugins/sib-reactions.js
@@ -243,6 +243,15 @@ converse.plugins.add('sib-reactions', {
             picker.remove();
           }
         });
+
+        // Close the picker if clicked outside of it
+        setTimeout(() => {
+          document.addEventListener('click', ev => {
+            if (!picker.shadowRoot.contains(ev.composedPath()[0])) {
+              picker.remove();
+            }
+          });
+        });
       },
 
       /**
@@ -330,6 +339,15 @@ converse.plugins.add('sib-reactions', {
               picker.remove();
             }
           });
+
+          // Close the picker if clicked outside of it
+          setTimeout(() => {
+            document.addEventListener('click', ev => {
+              if (!picker.shadowRoot.contains(ev.composedPath()[0])) {
+                picker.remove();
+              }
+            });
+          });
         },
         'button_class': 'chat-msg__action-react',
         'icon_class': 'fa fa-smile',
-- 
GitLab