From 5dd5c84854cf904c800a44b102cea590fc6673d2 Mon Sep 17 00:00:00 2001 From: Tejas Kasetty Date: Wed, 10 May 2017 23:16:20 +0530 Subject: [PATCH] Add support for emoji picker hotkeys in compose context. This is a follow-up to merging the compose and reactions emoji pickers. The logic for what happens when the user picks an emoji via the hotkeys (i.e. hits `enter`) was still attempting to add a reaction to the currently selected message unconditionally. This commit adds a check in the two `enter` key code paths, and does the correct thing in each case. Fixes #4736. --- static/js/emoji_picker.js | 4 ++++ static/js/hotkey.js | 6 +++++- static/js/reactions.js | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/static/js/emoji_picker.js b/static/js/emoji_picker.js index 2905886532..256abb6f82 100644 --- a/static/js/emoji_picker.js +++ b/static/js/emoji_picker.js @@ -182,6 +182,10 @@ exports.register_click_handlers = function () { }); }; +exports.is_composition = function (emoji) { + return emoji.classList.contains('composition'); +}; + return exports; }()); diff --git a/static/js/hotkey.js b/static/js/hotkey.js index b557873059..f1c97db647 100644 --- a/static/js/hotkey.js +++ b/static/js/hotkey.js @@ -245,7 +245,11 @@ exports.process_enter_key = function (e) { } if (emoji_picker.reactions_popped()) { - reactions.toggle_reaction(current_msg_list.selected_id()); + if (emoji_picker.is_composition(e.target)) { + e.target.click(); + } else { + reactions.toggle_reaction(current_msg_list.selected_id()); + } return true; } diff --git a/static/js/reactions.js b/static/js/reactions.js index e55b5464a9..dc85fc4ddc 100644 --- a/static/js/reactions.js +++ b/static/js/reactions.js @@ -116,7 +116,11 @@ function maybe_select_emoji(e) { e.preventDefault(); var first_emoji = get_emoji_at_index(0); if (first_emoji) { - exports.toggle_reaction(current_msg_list.selected_id(), first_emoji.title); + if (emoji_picker.is_composition(first_emoji)) { + first_emoji.click(); + } else { + exports.toggle_reaction(current_msg_list.selected_id(), first_emoji.title); + } } } }