summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPriyanka Kakadiya <pka@odoo.com>2021-03-25 13:10:14 +0000
committerPriyanka Kakadiya <pka@odoo.com>2021-03-26 10:33:55 +0000
commit2208a9b5e18881f5fbfea56872990daafba45579 (patch)
tree73b1f73e2861e13e15b385f09314a0e01dce742a
parent2e1bcb079ec361d85a80d790b8a2cc395055f09a (diff)
[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#68376 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
-rw-r--r--addons/mail/static/src/components/composer/composer_tests.js16
-rw-r--r--addons/mail/static/src/models/composer/composer.js3
2 files changed, 7 insertions, 12 deletions
diff --git a/addons/mail/static/src/components/composer/composer_tests.js b/addons/mail/static/src/components/composer/composer_tests.js
index da0a2fb2901..a4ff5978952 100644
--- a/addons/mail/static/src/components/composer/composer_tests.js
+++ b/addons/mail/static/src/components/composer/composer_tests.js
@@ -857,8 +857,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(
@@ -900,18 +900,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"
);
});
diff --git a/addons/mail/static/src/models/composer/composer.js b/addons/mail/static/src/models/composer/composer.js
index 035f70921f3..d20520e3385 100644
--- a/addons/mail/static/src/models/composer/composer.js
+++ b/addons/mail/static/src/models/composer/composer.js
@@ -726,6 +726,9 @@ function factory(dependencies) {
continue;
}
const candidateChar = this.textInputContent[candidatePosition];
+ if (candidateChar === '/' && candidatePosition !== 0) {
+ continue;
+ }
if (!suggestionDelimiters.includes(candidateChar)) {
continue;
}