From 396ac318d9591ec105964fffde59759abb6eceae Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Wed, 13 Apr 2022 13:14:37 +0000 Subject: [PATCH] [FIX] web_editor: restore m2m create text value before create Since [1] when the m2m widget was introduced, events that were neither from the create input text nor the create button did remove the internal value of the text that was entered in the create input text. Because of this "Create" had no effect if the user hovered e.g. a suggested blog tag on its way to pointing to the "Create" button. This commit replaces this behaviour by restoring the text value of the create input when the create button is used. [1]: https://github.com/odoo/odoo/commit/be05ac7e2b8d866a72693b761f3bc8576d54e59e task-2811746 X-original-commit: 59ecbb96db75a77cdcce11460cdbe8aa04438449 Part-of: odoo/odoo#109479 --- addons/web_editor/static/src/js/editor/snippets.options.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index 8e846ebe635..517bc881e53 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -2801,6 +2801,11 @@ const Many2oneUserValueWidget = SelectUserValueWidget.extend({ return; } if (widget && widget === this.createButton) { + // When the create button is clicked, make sure the text + // value is restored from the actual input element because + // it might have been removed when hovering existing tags. + // TODO review this, there is probably better to do + this.createInput._value = this.createInput.el.querySelector('input').value; if (!this.createInput._value) { ev.stopPropagation(); }