diff --git a/addons/mail/static/src/js/field_char.js b/addons/mail/static/src/js/field_char.js index 7fb99f89e8f..d176eae6e57 100644 --- a/addons/mail/static/src/js/field_char.js +++ b/addons/mail/static/src/js/field_char.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { debounce } from "@web/core/utils/timing"; import { FieldChar } from 'web.basic_fields'; FieldChar.include({ @@ -10,12 +11,16 @@ FieldChar.include({ /** * Support a key-based onchange in text field. - * The _triggerOnchange method is debounced to run 2 seconds after typing ends. + * The _triggerOnchange method is debounced to run after given debouce delay + * (or 2 seconds by default) on typing ends. * */ init: function () { this._super.apply(this, arguments); - this._triggerOnchange = _.debounce(this._triggerOnchange, 2000); + if (this.nodeOptions.keydown_debounce_delay === undefined) { + this.nodeOptions.keydown_debounce_delay = 2000; + } + this._triggerOnchange = debounce(this._triggerOnchange, this.nodeOptions.keydown_debounce_delay); }, @@ -44,7 +49,7 @@ FieldChar.include({ /** * Triggers the 'change' event to refresh the value. - * This method is debounced to run 2 seconds after typing ends. + * This method is debounced to run after given debouce delay on typing ends. * (to avoid spamming the server while the user is typing their message) * * @private diff --git a/addons/mail/static/src/js/field_emojis_common.js b/addons/mail/static/src/js/field_emojis_common.js index fae1c3dca1e..b1498c5ae05 100644 --- a/addons/mail/static/src/js/field_emojis_common.js +++ b/addons/mail/static/src/js/field_emojis_common.js @@ -1,5 +1,6 @@ /** @odoo-module **/ +import { debounce } from "@web/core/utils/timing"; import emojis from '@mail/js/emojis'; import MailEmojisMixin from '@mail/js/emojis_mixin'; import core from 'web.core'; @@ -17,7 +18,10 @@ var FieldEmojiCommon = { */ init: function () { this._super.apply(this, arguments); - this._triggerOnchange = _.debounce(this._triggerOnchange, 2000); + if (this.nodeOptions.keydown_debounce_delay === undefined) { + this.nodeOptions.keydown_debounce_delay = 2000; + } + this._triggerOnchange = debounce(this._triggerOnchange, this.nodeOptions.keydown_debounce_delay); this.emojis = emojis; }, @@ -89,7 +93,7 @@ var FieldEmojiCommon = { /** * Triggers the 'change' event to refresh the value. - * This method is debounced to run 2 seconds after typing ends. + * This method is debounced to run after given debouce delay on typing ends. * (to avoid spamming the server while the user is typing their message) * * @private