From ce3b09dff26396547e06e21e50ffe869dba64831 Mon Sep 17 00:00:00 2001 From: xO-Tx Date: Wed, 8 Sep 2021 15:38:50 +0000 Subject: [PATCH] [FIX] web_editor: fix empty save on dialogs I- mediaDialog/linkDialog: 1- Website editor > Add image/link using "/" commands. 2- The mediaDliaog/linkDialog will be shown to select item. 3- Click on "Add/Save" without selecting any image/setting any link. 4- traceback. II- mediaDialog (Video): The same flow for videos will add an empty ' + + '' + '' ); this.media = this.$media[0]; diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 387f2f2bfa9..4d3b3681cfe 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -849,6 +849,9 @@ const Wysiwyg = Widget.extend({ const restoreSelection = preserveCursor(this.odooEditor.document); linkDialog.open(); linkDialog.on('save', this, data => { + if (!data) { + return; + } const linkWidget = linkDialog.linkWidget; getDeepRange(this.$editable[0], {range: data.range, select: true}); if (!linkWidget.$link.length) { @@ -918,6 +921,9 @@ const Wysiwyg = Widget.extend({ mediaDialog.open(); mediaDialog.on('save', this, function (element) { + if (!element) { + return; + } // restore saved html classes if (params.htmlClass) { element.className += " " + params.htmlClass;