From 109ecd5205ad684a3ba85e94ce419c326696ec34 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 29 Jan 2018 15:05:02 +0100 Subject: [FIX] web_editor: firefox RTEWidget if hidden It seems that firefox has some difference of behavior from other browsers as said in: - https://bugzilla.mozilla.org/show_bug.cgi?id=548397 - https://github.com/whatwg/html/issues/1813 - https://github.com/w3c/csswg-drafts/issues/571 It seems that at least in one instance (a html field hidden on the pos configuration), firefox fails because of something similar: window.getComputedStyle(element) returns `null` instead of the element styles. In my tests, using the parent window (possible if current frame and parent have the same origin which should be the case) worked in this instance, this is examplified by this jsfiddle: https://jsfiddle.net/Lpv898ve/2/ This work with window.parent and not using window directly. So this commit adds fallback on doing getComputedStyle from the parent window (when testing on chromium this gave exactly the same result that before). opw-813363 fixes #22211 closes #22610 --- addons/web_editor/static/src/js/editor/rte.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'addons/web_editor/static/src/js/editor/rte.js') diff --git a/addons/web_editor/static/src/js/editor/rte.js b/addons/web_editor/static/src/js/editor/rte.js index 014a3faf40e..ee0ec7932c0 100644 --- a/addons/web_editor/static/src/js/editor/rte.js +++ b/addons/web_editor/static/src/js/editor/rte.js @@ -281,8 +281,10 @@ var RTEWidget = Widget.extend({ .each(function () { var $node = $(this); + // fallback for firefox iframe display:none see https://github.com/odoo/odoo/pull/22610 + var computedStyles = window.getComputedStyle(this) || window.parent.getComputedStyle(this); // add class to display inline-block for empty t-field - if (window.getComputedStyle(this).display === 'inline' && $node.data('oe-type') !== 'image') { + if (computedStyles.display === 'inline' && $node.data('oe-type') !== 'image') { $node.addClass('o_is_inline_editable'); } }); -- cgit v1.2.3