From 3f320c8a93e2895b00131801327d6066c278e2f1 Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Mon, 16 Jan 2023 09:08:24 +0000 Subject: [PATCH] [FIX] web_editor: fix toolbar not hiding when clicking outside of editable Commit [1] correctly disabled some of the behaviors of the editor that used to modify the selection outside of the editable. However, it also had the inadvertent side-effect of disabling the toolbar update mechanism when clicking outside of the editable. Behavior before this commit: When the toolbar is visible, clicking outside the editable zone does not hide the toolbar. Behavior after this commit: Clicking outside of the editable zone hides the toolbar. [1]: 07a14839671ee516db124b18f5b58d6ad08f382d task-3131435 closes odoo/odoo#110044 X-original-commit: 28a35a6b53493abd03e42cc30d164262c86b6de5 Signed-off-by: David Monjoie (dmo) --- .../js/editor/odoo-editor/src/OdooEditor.js | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 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 cdd4a876f99..f6b7ac1efea 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 @@ -3536,6 +3536,17 @@ export class OdooEditor extends EventTarget { return; } + let appliedCustomSelection = false; + if (selection.rangeCount && selection.getRangeAt(0)) { + appliedCustomSelection = this._handleSelectionInTable(); + if (this.options.onCollaborativeSelectionChange) { + this.options.onCollaborativeSelectionChange(this.getCurrentCollaborativeSelection()); + } + } + if (!appliedCustomSelection) { + this._updateToolbar(!selection.isCollapsed && this.isSelectionInEditable(selection)); + } + if ( !this.editable.contains(selection.anchorNode) && !this.editable.contains(selection.focusNode) @@ -3567,16 +3578,6 @@ export class OdooEditor extends EventTarget { if (this._currentMouseState === 'mouseup') { this._fixFontAwesomeSelection(); } - let appliedCustomSelection = false; - if (selection.rangeCount && selection.getRangeAt(0)) { - appliedCustomSelection = this._handleSelectionInTable(); - if (this.options.onCollaborativeSelectionChange) { - this.options.onCollaborativeSelectionChange(this.getCurrentCollaborativeSelection()); - } - } - if (!appliedCustomSelection) { - this._updateToolbar(!selection.isCollapsed && this.isSelectionInEditable(selection)); - } } /**