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.
This commit is contained in:
Tejas Kasetty
2017-05-10 23:16:20 +05:30
committed by Tim Abbott
parent 52059d21a4
commit 5dd5c84854
3 changed files with 14 additions and 2 deletions

View File

@@ -182,6 +182,10 @@ exports.register_click_handlers = function () {
}); });
}; };
exports.is_composition = function (emoji) {
return emoji.classList.contains('composition');
};
return exports; return exports;
}()); }());

View File

@@ -245,7 +245,11 @@ exports.process_enter_key = function (e) {
} }
if (emoji_picker.reactions_popped()) { 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; return true;
} }

View File

@@ -116,7 +116,11 @@ function maybe_select_emoji(e) {
e.preventDefault(); e.preventDefault();
var first_emoji = get_emoji_at_index(0); var first_emoji = get_emoji_at_index(0);
if (first_emoji) { 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);
}
} }
} }
} }