From 386875cf3d89b5e6412f88d83fd146a3092140db Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Tue, 13 Apr 2021 10:29:22 +0000 Subject: [PATCH] [FIX] web_editor: prevent traceback on select image Trying to select the contents of a content-less element should select the element itself instead. closes odoo/odoo#69173 X-original-commit: 6905eaad2ccaa782e3dce99b9581ed0194c37db9 Signed-off-by: David Monjoie (dmo) --- addons/web_editor/static/src/js/editor/snippets.editor.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index cdfdf1b4908..30b92a3184f 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -78,6 +78,9 @@ $.fn.extend({ return this; }, selectContent: function () { + if (this.length && !this[0].hasChildNodes()) { + return this.selectElement(); + } if (this.length) { const selection = document.getSelection(); selection.removeAllRanges();