Fixed enter

Closes #691
This commit is contained in:
Igor Zhukov 2015-02-13 14:56:34 +03:00
parent 264c14c9f4
commit a87ae20055

View File

@ -501,6 +501,7 @@ MessageComposer.prototype.onKeyEvent = function (e) {
} }
if (e.type == 'keydown') { if (e.type == 'keydown') {
var checkSubmit = !this.autocompleteShown;
if (this.autocompleteShown) { if (this.autocompleteShown) {
if (e.keyCode == 38 || e.keyCode == 40) { // UP / DOWN if (e.keyCode == 38 || e.keyCode == 40) { // UP / DOWN
var next = e.keyCode == 40; var next = e.keyCode == 40;
@ -524,18 +525,19 @@ MessageComposer.prototype.onKeyEvent = function (e) {
} }
if (e.keyCode == 13) { // ENTER if (e.keyCode == 13) { // ENTER
var currentSelected = $(this.autoCompleteEl).find('.composer_emoji_option_active') || var currentSelected = $(this.autoCompleteEl).find('.composer_emoji_option_active')/* ||
$(this.autoCompleteEl).childNodes[0].find('a'); $(this.autoCompleteEl).childNodes[0].find('a')*/;
var code = currentSelected.attr('data-code'); var code = currentSelected.attr('data-code');
if (code) { if (code) {
this.onEmojiSelected(code, true); this.onEmojiSelected(code, true);
EmojiHelper.pushPopularEmoji(code); EmojiHelper.pushPopularEmoji(code);
return cancelEvent(e);
} }
return cancelEvent(e); checkSubmit = true;
} }
} }
else if (e.keyCode == 13) { if (checkSubmit && e.keyCode == 13) {
var submit = false; var submit = false;
var sendOnEnter = true; var sendOnEnter = true;
if (this.getSendOnEnter && !this.getSendOnEnter()) { if (this.getSendOnEnter && !this.getSendOnEnter()) {