From c7a5ed99ba08d8e513c53fc23fdb52acb3105ebd Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Thu, 4 May 2023 13:22:31 +0000 Subject: [PATCH] [FIX] web_editor: properly handle exec toolbar command after input click When clicking on an input in the toolbar, the selection was lost and the commands could not be executed. This restores the latest selection in the editable in these cases. Part-of: odoo/odoo#119972 --- .../src/js/editor/odoo-editor/src/OdooEditor.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js index 4d6c7da5bc2..5e90c08f1f8 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js @@ -1852,13 +1852,13 @@ export class OdooEditor extends EventTarget { bindExecCommand(element) { for (const buttonEl of element.querySelectorAll('[data-call]')) { buttonEl.addEventListener('click', ev => { - const sel = this.document.getSelection(); - if (sel.anchorNode && ancestors(sel.anchorNode).includes(this.editable)) { - this.execCommand(buttonEl.dataset.call, buttonEl.dataset.arg1); - - ev.preventDefault(); - this._updateToolbar(); + if (!this.isSelectionInEditable()) { + this.historyResetLatestComputedSelection(true); } + this.execCommand(buttonEl.dataset.call, buttonEl.dataset.arg1); + + ev.preventDefault(); + this._updateToolbar(); }); } }