From 2a0e8d1993868aec4b3aa555838e5d9cd1453033 Mon Sep 17 00:00:00 2001 From: Nicolas Bayet Date: Wed, 25 Jan 2023 10:32:18 +0000 Subject: [PATCH] [FIX] web_editor: fix _getEditorOptions traceback Before this commit, a traceback would be thrown when no options were passed to `_getEditorOptions` because of a code mistake using the variable `options` rather than `finalOptions`. Also, this error revealed that the `this.options` of the wysiwyg could be wrongly reset if no argument `options` was passed to `resetEditor`. task-3149085 closes odoo/odoo#111100 X-original-commit: 475775d3dfc230c06c7a2b127b67bc22543e8a27 Signed-off-by: Antoine Guenet (age) --- addons/web_editor/static/src/js/wysiwyg/wysiwyg.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index 1c412db9464..95ee97ba35b 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -2013,7 +2013,7 @@ const Wysiwyg = Widget.extend({ // autohideToolbar is true by default (false by default if navbar present). finalOptions.autohideToolbar = typeof finalOptions.autohideToolbar === 'boolean' ? finalOptions.autohideToolbar - : !options.snippets; + : !finalOptions.snippets; return finalOptions; }, @@ -2535,8 +2535,10 @@ const Wysiwyg = Widget.extend({ this._collaborationStopBus && this._collaborationStopBus(); }, resetEditor: function (value, options) { - this.options = this._getEditorOptions(options); - const {collaborationChannel} = options; + if (options) { + this.options = this._getEditorOptions(options); + } + const {collaborationChannel} = this.options; this._stopPeerToPeer(); // If there is no collaborationResId, the record has been deleted. if (!collaborationChannel || !collaborationChannel.collaborationResId) {