Skip to content
Snippets Groups Projects
Commit 048612f2 authored by xO-Tx's avatar xO-Tx
Browse files

[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

closes odoo/odoo#67171

closes odoo/odoo#67176

X-original-commit: 9a16c313f131ed2e1017566a5f1bed134e22cc10
Signed-off-by: default avatarQuentin Smetz (qsm) <qsm@odoo.com>
parent a0628290
Branches
Tags
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment