[FIX] mail: command suggestion should only show if '/' is first char

PURPOSE:

command suggestion should only open if command is the first char.

SPECIFICATION:

command suggestion should only open if command is the first char.

Task-2487518

closes odoo/odoo#68428

X-original-commit: 2208a9b5e18881f5fbfea56872990daafba45579
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Priyanka Kakadiya
2021-03-26 19:52:37 +00:00
parent 49663be314
commit fc34260bee
2 changed files with 7 additions and 12 deletions
@@ -952,8 +952,8 @@ QUnit.test("channel with no commands should not prompt any command suggestions o
);
});
QUnit.test('use a command after some text', async function (assert) {
assert.expect(5);
QUnit.test('command suggestion should only open if command is the first character', async function (assert) {
assert.expect(4);
this.data['mail.channel'].records.push({ channel_type: 'channel', id: 20 });
this.data['mail.channel_command'].records.push(
@@ -995,18 +995,10 @@ QUnit.test('use a command after some text', async function (assert) {
document.querySelector(`.o_ComposerTextInput_textarea`)
.dispatchEvent(new window.KeyboardEvent('keyup'));
});
assert.containsOnce(
assert.containsNone(
document.body,
'.o_ComposerSuggestion',
"should have a command suggestion"
);
await afterNextRender(() =>
document.querySelector('.o_ComposerSuggestion').click()
);
assert.strictEqual(
document.querySelector(`.o_ComposerTextInput_textarea`).value.replace(/\s/, " "),
"bluhbluh /who ",
"text content of composer should have previous content + used command + additional whitespace afterwards"
"should not have a command suggestion"
);
});
@@ -553,6 +553,9 @@ function factory(dependencies) {
continue;
}
const candidateChar = this.textInputContent[candidatePosition];
if (candidateChar === '/' && candidatePosition !== 0) {
continue;
}
if (!suggestionDelimiters.includes(candidateChar)) {
continue;
}