From b6757cbcdbdf3eb3d8d44c3ad784a5194f95c266 Mon Sep 17 00:00:00 2001 From: Jinjiu Liu Date: Fri, 6 Oct 2023 10:44:24 +0200 Subject: [PATCH] [FIX] web_editor: text's first-click selection not set after link click Reproduction: 1. in Website, enter Editing mode, drag a block with a button, for example, banner 2. click on the button then click on the text above the button 3. the selection should be around the text paragraph, but it's on the button Note the behavior is only for the first time of clicking on the element, e.g. when dragging and dropping a new block Fix: The selection restoration when destroying the link tools should be done on the spot instead of binding to the destroy of linkToolsInfos. Without this fix, the selection restore in link tool is done after the full selection step for o_default_snippet_text element task-3514638 closes odoo/odoo#139031 X-original-commit: 6dcc33c6c85b605f43e8f42a5d4013eca9e0ef7a Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 600314e6427..bcfd6866fd2 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -1454,9 +1454,7 @@ export class Wysiwyg extends Component { } this.linkToolsInfos.removeHintClasses(); if (anchorNode) { - this.linkToolsInfos.onDestroy = () => { - setSelection(anchorNode, anchorOffset, focusNode, focusOffset, false); - } + setSelection(anchorNode, anchorOffset, focusNode, focusOffset, false); } this.state.linkToolProps = undefined; }