From 90f296b649655ba00fece1f1e67a17b37d818ecb Mon Sep 17 00:00:00 2001 From: ubermanu <e.vodor@gmail.com> Date: Tue, 16 Mar 2021 22:01:22 +0100 Subject: [PATCH] focus the search input and close on escape key --- src/plugins/sib-reactions.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/plugins/sib-reactions.js b/src/plugins/sib-reactions.js index 7a3fbf0..eb9c9a4 100644 --- a/src/plugins/sib-reactions.js +++ b/src/plugins/sib-reactions.js @@ -232,6 +232,17 @@ converse.plugins.add('sib-reactions', { sendReactionStanza(self.model, emojis); }); + + // Focus the search input when the picker opens + const emojiSearch = picker.shadowRoot?.querySelector('.search'); + emojiSearch?.focus(); + + // Close the picker if the ESC key is pressed + picker.addEventListener('keydown', ev => { + if (ev.key === 'Escape') { + picker.remove(); + } + }); }, /** @@ -308,6 +319,17 @@ converse.plugins.add('sib-reactions', { sendReactionStanza(el.model, emojis); }); + + // Focus the search input when the picker opens + const emojiSearch = picker.shadowRoot?.querySelector('.search'); + emojiSearch?.focus(); + + // Close the picker if the ESC key is pressed + picker.addEventListener('keydown', ev => { + if (ev.key === 'Escape') { + picker.remove(); + } + }); }, 'button_class': 'chat-msg__action-react', 'icon_class': 'fa fa-smile', -- GitLab