From 13c326caaa38eb8c1f9341da854a5045949fcf24 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 30 Jan 2018 15:01:39 +0100 Subject: [PATCH] [FIX] web_editor: firefox editor hidden mass mail When saving a modified mass mailing, the editor will do a number of things to improve the mail readability accross mail client. One of those is replacing font awesome icons by image, but firefox acts differently than other browser. On a display:none iframe, doing .css('color') or .height() on an element returns respectively `undefined` and 0. This caused an error when getting the color that we could solve by doing a fallback for firefox like this: window.parent.getComputedStyle($font[0]).color But to get the height() of an element, it seems we always need the iframe displayed. With this change, when the iframe is hidden and the browser is firefox, the code try to display the iframe (with "visibility:hidden;height:1px") when this part of the code happen. opw-807180 closes #22639 --- addons/web_editor/static/src/js/backend.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/web_editor/static/src/js/backend.js b/addons/web_editor/static/src/js/backend.js index f4f8d7144b6..23505c082fa 100644 --- a/addons/web_editor/static/src/js/backend.js +++ b/addons/web_editor/static/src/js/backend.js @@ -405,7 +405,19 @@ var FieldTextHtml = widget.extend({ var layoutInfo = this.editor.rte.editable().data('layoutInfo'); $.summernote.pluginEvents.codeview(undefined, undefined, layoutInfo, false); } + var $ancestors = this.$iframe.filter(':not(:visible)').parentsUntil(':visible').addBack(); + var ancestorsStyle = []; + // temporarily force displaying iframe (needed for firefox) + _.each($ancestors, function (el) { + var $el = $(el); + ancestorsStyle.unshift($el.attr('style') || null); + $el.css({display: 'initial', visibility: 'hidden', height: 1}); + }); this.editor.buildingBlock.clean_for_save(); + _.each($ancestors, function (el) { + var $el = $(el); + $el.attr('style', ancestorsStyle.pop()); + }); this.internal_set_value( this.$content.html() ); } },