summaryrefslogtreecommitdiff
path: root/addons/web_editor/static
diff options
context:
space:
mode:
authorxO-Tx <mou@odoo.com>2021-02-22 18:44:45 +0000
committerxO-Tx <mou@odoo.com>2021-02-22 18:44:45 +0000
commit8b89a5a57bb074691cab0aed32428564bdef3a07 (patch)
treef8e477bb5d7195a52408a22c895060c141f68f82 /addons/web_editor/static
parentd9cb38769ecc0f124a6a5dff191bc2094c527106 (diff)
[FIX] web_editor: fix anchor range selection
When we double click a form submit anchor, and depending on the selected element before click, the selection range ("document.getSelection()") can start from a parent of the targeted node. This will send a wrong range to be used in LinkDialog widget. The goal of this commit is to prevent this behaviour by adjusting the range if it starts from anchor parent. Note: the bug only occurred in Firefox. Part of https://github.com/odoo/odoo/pull/62206 task-2381305 closes odoo/odoo#62206 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/web_editor/static')
-rw-r--r--addons/web_editor/static/lib/summernote/src/js/module/Editor.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/addons/web_editor/static/lib/summernote/src/js/module/Editor.js b/addons/web_editor/static/lib/summernote/src/js/module/Editor.js
index b5e3190ce2e..cdba12eb964 100644
--- a/addons/web_editor/static/lib/summernote/src/js/module/Editor.js
+++ b/addons/web_editor/static/lib/summernote/src/js/module/Editor.js
@@ -711,7 +711,13 @@ define([
var rng = range.create().expand(dom.isAnchor);
// Get the first anchor on range(for edit).
- var $anchor = $(list.head(rng.nodes(dom.isAnchor)));
+ var anchor = list.head(rng.nodes(dom.isAnchor));
+ const $anchor = $(anchor);
+
+ if ($anchor.length && !rng.nodes()[0].isSameNode(anchor)) {
+ rng = range.createFromNode(anchor);
+ rng.select();
+ }
// Check if the target is a button element.
let isButton = false;