[FIX] mail: backport fixes on the composer from saas-11.2
This commit back-port some fixes from saas-11.2 on composer. Tests are available only in saas-11.2 and up. List of fixes: 1. Pressing TAB with @ mention propositions should cycle through them (see https://github.com/odoo/odoo/commit/497a44ab7f04e377decf5fde42f075616f764f26) 2. Prevent a crash when focusing out the emoji button (see https://github.com/odoo/odoo/commit/1753017255f3f078ede05a68842f440e02b64630)
This commit is contained in:
@@ -145,24 +145,6 @@ var MentionManager = Widget.extend({
|
||||
return selections;
|
||||
},
|
||||
|
||||
proposition_navigation: function (keycode) {
|
||||
var $active = this.$('.o_mention_proposition.active');
|
||||
if (keycode === $.ui.keyCode.ENTER) { // selecting proposition
|
||||
$active.click();
|
||||
} else { // navigation in propositions
|
||||
var $to;
|
||||
if (keycode === $.ui.keyCode.DOWN) {
|
||||
$to = $active.nextAll('.o_mention_proposition').first();
|
||||
} else {
|
||||
$to = $active.prevAll('.o_mention_proposition').first();
|
||||
}
|
||||
if ($to.length) {
|
||||
$active.removeClass('active');
|
||||
$to.addClass('active');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Detects if the user is currently typing a mention word
|
||||
* @return the search string if it is, false otherwise
|
||||
@@ -286,6 +268,32 @@ var MentionManager = Widget.extend({
|
||||
}
|
||||
return result;
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @param {integer} keycode
|
||||
*/
|
||||
_propositionNavigation: function (keycode) {
|
||||
var $active = this.$('.o_mention_proposition.active');
|
||||
if (keycode === $.ui.keyCode.ENTER) { // selecting proposition
|
||||
$active.click();
|
||||
} else { // navigation in propositions
|
||||
var $to;
|
||||
if (keycode === $.ui.keyCode.DOWN) {
|
||||
$to = $active.nextAll('.o_mention_proposition').first();
|
||||
} else if (keycode === $.ui.keyCode.UP) {
|
||||
$to = $active.prevAll('.o_mention_proposition').first();
|
||||
} else if (keycode === $.ui.keyCode.TAB) {
|
||||
$to = $active.nextAll('.o_mention_proposition').first();
|
||||
if (!$to.length) {
|
||||
$to = $active.prevAll('.o_mention_proposition').last();
|
||||
}
|
||||
}
|
||||
if ($to && $to.length) {
|
||||
$active.removeClass('active');
|
||||
$to.addClass('active');
|
||||
}
|
||||
}
|
||||
},
|
||||
_render_suggestions: function () {
|
||||
var suggestions = [];
|
||||
if (_.find(this.get('mention_suggestions'), _.isArray)) {
|
||||
@@ -522,9 +530,10 @@ var BasicComposer = Widget.extend(chat_mixin, {
|
||||
|
||||
on_keydown: function (event) {
|
||||
switch(event.which) {
|
||||
// UP, DOWN: prevent moving cursor if navigation in mention propositions
|
||||
// UP, DOWN, TAB: prevent moving cursor if navigation in mention propositions
|
||||
case $.ui.keyCode.UP:
|
||||
case $.ui.keyCode.DOWN:
|
||||
case $.ui.keyCode.TAB:
|
||||
if (this.mention_manager.is_open()) {
|
||||
event.preventDefault();
|
||||
}
|
||||
@@ -560,12 +569,13 @@ var BasicComposer = Widget.extend(chat_mixin, {
|
||||
this.trigger_up("escape_pressed");
|
||||
}
|
||||
break;
|
||||
// ENTER, UP, DOWN: check if navigation in mention propositions
|
||||
// ENTER, UP, DOWN, TAB: check if navigation in mention propositions
|
||||
case $.ui.keyCode.ENTER:
|
||||
case $.ui.keyCode.UP:
|
||||
case $.ui.keyCode.DOWN:
|
||||
case $.ui.keyCode.TAB:
|
||||
if (this.mention_manager.is_open()) {
|
||||
this.mention_manager.proposition_navigation(event.which);
|
||||
this.mention_manager._propositionNavigation(event.which);
|
||||
}
|
||||
break;
|
||||
// Otherwise, check if a mention is typed
|
||||
@@ -814,7 +824,9 @@ var BasicComposer = Widget.extend(chat_mixin, {
|
||||
* @private
|
||||
*/
|
||||
_onEmojiButtonFocusout: function () {
|
||||
this._hideEmojisTimeout = setTimeout(this._hideEmojis.bind(this), 0);
|
||||
if (this.$emojisContainer) {
|
||||
this._hideEmojisTimeout = setTimeout(this._hideEmojis.bind(this), 0);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Called when an emoji is focused -> @see _onEmojiButtonFocusout
|
||||
|
||||
Reference in New Issue
Block a user