From 1f42c0f46852ef1cd2787c757d866eac14ce2959 Mon Sep 17 00:00:00 2001 From: Jinjiu Liu Date: Thu, 10 Aug 2023 14:01:02 +0200 Subject: [PATCH] [FIX] web_editor: cursor one step late in collaboration Reproduction: 1. Install note 2. Open an existing note and open it again in another tab 3. When you click in one tab, the cursor position in the other one is always one step behind Fix: separate the logic between collaboration and appliedCustomSelection and revert the calling of getCurrentCollaborativeSelection to the place after _computeHistorySelection Task-3221119 closes odoo/odoo#144929 X-original-commit: 854ef7df4db577d010bed9a3561c57b3700447d8 Signed-off-by: Nicolas Bayet (nby) --- .../static/src/js/editor/odoo-editor/src/OdooEditor.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 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 7f80d848b53..3e76e670826 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 @@ -4100,9 +4100,6 @@ export class OdooEditor extends EventTarget { // wasn't changed. this._setLinkZws(); - if (this.options.onCollaborativeSelectionChange) { - this.options.onCollaborativeSelectionChange(this.getCurrentCollaborativeSelection()); - } } const isSelectionInEditable = this.isSelectionInEditable(selection); if (!appliedCustomSelection) { @@ -4135,6 +4132,13 @@ export class OdooEditor extends EventTarget { if (this._currentMouseState === 'mouseup') { this._fixFontAwesomeSelection(); } + if ( + selection.rangeCount && + selection.getRangeAt(0) && + this.options.onCollaborativeSelectionChange + ) { + this.options.onCollaborativeSelectionChange(this.getCurrentCollaborativeSelection()); + } } /**