summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/components/composer_text_input
diff options
context:
space:
mode:
authorXavier Dubuc <xdu@odoo.com>2020-08-20 13:31:23 +0000
committerAlexandre Kühn <aku@odoo.com>2020-09-03 14:34:28 +0000
commit586496abcf802794bb9eaa70cae3654644e01f86 (patch)
tree1fe148ecee7a5611a0111cad9ccfb4398075f306 /addons/mail/static/src/components/composer_text_input
parent09d5386a373c5a37aa2273188b1038deeef79648 (diff)
[FIX] mail: allow composer text input to send message with ctrl+enter
Also allow meta+enter task-2296863 closes odoo/odoo#57045 X-original-commit: 6bad3666be3d3631eaadae409d0cabcdd02661a8 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components/composer_text_input')
-rw-r--r--addons/mail/static/src/components/composer_text_input/composer_text_input.js63
1 files changed, 50 insertions, 13 deletions
diff --git a/addons/mail/static/src/components/composer_text_input/composer_text_input.js b/addons/mail/static/src/components/composer_text_input/composer_text_input.js
index 6a0943f9ca8..ef21d023cb5 100644
--- a/addons/mail/static/src/components/composer_text_input/composer_text_input.js
+++ b/addons/mail/static/src/components/composer_text_input/composer_text_input.js
@@ -241,18 +241,41 @@ class ComposerTextInput extends Component {
_onKeydownTextareaEnter(ev) {
if (this.composer.hasSuggestedPartners) {
ev.preventDefault();
- } else {
- if (!this.props.hasSendOnEnterEnabled) {
- return;
- }
- if (ev.shiftKey) {
- return;
- }
- if (this.env.messaging.device.isMobile) {
- return;
- }
- this.trigger('o-keydown-enter');
+ return;
+ }
+ if (
+ this.props.sendShortcuts.includes('ctrl-enter') &&
+ !ev.altKey &&
+ ev.ctrlKey &&
+ !ev.metaKey &&
+ !ev.shiftKey
+ ) {
+ this.trigger('o-composer-text-input-send-shortcut');
+ ev.preventDefault();
+ return;
+ }
+ if (
+ this.props.sendShortcuts.includes('enter') &&
+ !ev.altKey &&
+ !ev.ctrlKey &&
+ !ev.metaKey &&
+ !ev.shiftKey &&
+ !this.env.messaging.device.isMobile
+ ) {
+ this.trigger('o-composer-text-input-send-shortcut');
ev.preventDefault();
+ return;
+ }
+ if (
+ this.props.sendShortcuts.includes('meta-enter') &&
+ !ev.altKey &&
+ !ev.ctrlKey &&
+ ev.metaKey &&
+ !ev.shiftKey
+ ) {
+ this.trigger('o-composer-text-input-send-shortcut');
+ ev.preventDefault();
+ return;
}
}
@@ -341,13 +364,27 @@ Object.assign(ComposerTextInput, {
components,
defaultProps: {
hasMentionSuggestionsBelowPosition: false,
- hasSendOnEnterEnabled: true,
+ sendShortcuts: [],
},
props: {
composerLocalId: String,
hasMentionSuggestionsBelowPosition: Boolean,
- hasSendOnEnterEnabled: Boolean,
isCompact: Boolean,
+ /**
+ * Keyboard shortcuts from text input to send message.
+ */
+ sendShortcuts: {
+ type: Array,
+ element: String,
+ validate: prop => {
+ for (const shortcut of prop) {
+ if (!['ctrl-enter', 'enter', 'meta-enter'].includes(shortcut)) {
+ return false;
+ }
+ }
+ return true;
+ },
+ },
},
template: 'mail.ComposerTextInput',
});