From f2a44d192dbec1897aa592149adb49b2d8c3af9e Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Tue, 5 Oct 2021 09:18:03 +0000 Subject: [PATCH] [FIX] web_editor: handle gradient styles only when gradients allowed Before this commit the progress bar options were broken because the stripe effect is achieved by a gradient in the CSS, but `SnippetOptionWidget` recognized it as a manually selected gradient, and thus applied the gradient specific handling (such as neutralizing the background-image when a color is selected). After this commit the special handling for gradients is only applied where gradients are expected to be selected manually (i.e. when the `withGradients` parameter is set). task-2662401 closes odoo/odoo#77881 X-original-commit: f873c1d1eb05fa25717817c85899629103dcada3 Signed-off-by: Quentin Smetz (qsm) --- addons/web_editor/static/src/js/editor/snippets.options.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index 43997186007..9c7fd7747f0 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -3134,7 +3134,7 @@ const SnippetOptionWidget = Widget.extend({ // method with background-color as property too, so it is automatically // reset anyway). let bgImageParts = undefined; - if (params.cssProperty === 'background-color') { + if (params.withGradients && params.cssProperty === 'background-color') { const styles = getComputedStyle(this.$target[0]); bgImageParts = backgroundImageCssToParts(styles['background-image']); delete bgImageParts.gradient; @@ -3185,7 +3185,7 @@ const SnippetOptionWidget = Widget.extend({ // In case of background-color edition, we could receive a gradient, in // which case the value has to be combined with the potential background // image (real image). - if (params.cssProperty === 'background-color' && weUtils.isColorGradient(widgetValue)) { + if (params.withGradients && params.cssProperty === 'background-color' && weUtils.isColorGradient(widgetValue)) { cssProps = ['background-image']; bgImageParts.gradient = widgetValue; widgetValue = backgroundImagePartsToCss(bgImageParts); @@ -3550,7 +3550,7 @@ const SnippetOptionWidget = Widget.extend({ const styles = window.getComputedStyle(this.$target[0]); - if (params.cssProperty === 'background-color') { + if (params.withGradients && params.cssProperty === 'background-color') { // Check if there is a gradient, in that case this is the // value to be returned, we normally not allow color and // gradient at the same time (the option would remove one