[FIX] mail: fix text selection in composer using SHIFT and arrow keys

This commit corrects the faulty SHIFT + ArrowKey selection behavior.

task-2388650

closes odoo/odoo#62251

X-original-commit: d498f899aa2ef81acbcd035896b9fcc912e4d52b
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Julien Giannone
2020-11-24 14:24:48 +00:00
parent 64b95a01d0
commit 01b5bf1442
2 changed files with 10 additions and 2 deletions
@@ -97,8 +97,9 @@ class ComposerTextInput extends Component {
saveStateInStore() {
this.composer.update({
textInputContent: this._getContent(),
textInputCursorStart: this._getSelectionStart(),
textInputCursorEnd: this._getSelectionEnd(),
textInputCursorStart: this._getSelectionStart(),
textInputSelectionDirection: this._textareaRef.el.selectionDirection,
});
}
@@ -159,7 +160,8 @@ class ComposerTextInput extends Component {
this._textareaRef.el.value = this.composer.textInputContent;
this._textareaRef.el.setSelectionRange(
this.composer.textInputCursorStart,
this.composer.textInputCursorEnd
this.composer.textInputCursorEnd,
this.composer.textInputSelectionDirection,
);
this._updateHeight();
}
@@ -45,6 +45,9 @@ function factory(dependencies) {
}
detectSuggestionDelimiter() {
if (this.textInputCursorStart !== this.textInputCursorEnd) {
return;
}
const lastInputChar = this.textInputContent.substring(this.textInputCursorStart - 1, this.textInputCursorStart);
const suggestionDelimiters = ['@', ':', '#', '/'];
if (suggestionDelimiters.includes(lastInputChar) && !this.hasSuggestions) {
@@ -1043,6 +1046,9 @@ function factory(dependencies) {
textInputCursorStart: attr({
default: 0,
}),
textInputSelectionDirection: attr({
default: "none",
}),
thread: one2one('mail.thread', {
inverse: 'composer',
}),