summaryrefslogtreecommitdiff
path: root/addons/web_editor
diff options
context:
space:
mode:
authorxO-Tx <mou@odoo.com>2021-02-10 12:45:29 +0000
committerqsm-odoo <qsm@odoo.com>2021-02-19 16:24:35 +0000
commitadf3d039acbac60b7ea7e6ab0ea8fdd9f940c3b2 (patch)
tree91fac1ffbd610b51aa4689e5af161e6b3adff633 /addons/web_editor
parent367ffd7757cf892c2ad08cc0bf35f23d78083ccc (diff)
[FIX] web_editor: fix anchor click on submit button
Context: 1) Edit mode 2) Click on anchor edition button of website form submit button 3) Traceback occurs The "focus" triggered on $editable element in editor's 'getLinkInfo()' discards user's text selection on submit button, as a result, 'range.create()' method returns null since no selection is found. Note: the bug only occurred in Chrome. Note 2: [1] apparently tried to solve the same issue but the fix was not solving it correctly, at least not in all cases. [1]: https://github.com/odoo/odoo/commit/da14e4449e5e318eb72e1b9f268fb797adb0c6a6 opw-2443441 closes odoo/odoo#66552 X-original-commit: d2f3c9e7975188753fa17c06db3fc5c73c773944 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/web_editor')
-rw-r--r--addons/web_editor/static/lib/summernote/src/js/module/Editor.js19
1 files changed, 19 insertions, 0 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 0b63f315cf9..40b7c95e98d 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
@@ -680,8 +680,27 @@ define([
* @return {String} [return.url=""]
*/
this.getLinkInfo = function ($editable) {
+ // ODOO MODIFICATION START
+ var selection;
+ var currentSelection = null;
+ if (document.getSelection) {
+ selection = document.getSelection();
+ if (selection.getRangeAt && selection.rangeCount) {
+ currentSelection = selection.getRangeAt(0);
+ }
+ }
+ // ODOO MODIFICATION END
+
this.focus($editable);
+ // ODOO MODIFICATION START
+ if (currentSelection && document.getSelection) {
+ selection = document.getSelection();
+ selection.removeAllRanges();
+ selection.addRange(currentSelection);
+ }
+ // ODOO MODIFICATION END
+
var rng = range.create().expand(dom.isAnchor);
// Get the first anchor on range(for edit).