Skip to content

Commit

Permalink
autocomplete enterkey lock
Browse files Browse the repository at this point in the history
When pressing enter to selecting an emoji in the autocompletion
dropdown, there is a trigger event. And we need to distigish if the
enter was pressed to send the message or to seletect the emoji. This
simple lock variable should help with that.
  • Loading branch information
imsys committed Nov 17, 2021
1 parent 1316bee commit de7302c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/function/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function($, emojione, blankImg, slice, css_class, emojioneSupportMode, invisible
self.emojiTemplateAlt = self.sprite ? '<i class="emojione-{uni}"/>' : '<img class="emojioneemoji" src="{img}" crossorigin/>';
self.emojiBtnTemplate = '<i class="emojibtn" role="button" data-name="{name}" title="{friendlyName}">' + self.emojiTemplateAlt + '</i>';
self.recentEmojis = options.recentEmojis && supportsLocalStorage();
self.autocomplete_enter_lock = false;

var pickerPosition = options.pickerPosition;
self.floatingPicker = pickerPosition === 'top' || pickerPosition === 'bottom';
Expand Down Expand Up @@ -560,6 +561,7 @@ function($, emojione, blankImg, slice, css_class, emojioneSupportMode, invisible
if (options.shortcuts) {
textcompleteOptions.onKeydown = function (e, commands) {
if (!e.ctrlKey && e.which == 13) {
self.autocomplete_enter_lock = true;
return commands.KEY_ENTER;
}
};
Expand Down

0 comments on commit de7302c

Please sign in to comment.