diff options
| author | Samuel Degueldre <sad@odoo.com> | 2020-09-18 11:35:49 +0000 |
|---|---|---|
| committer | Samuel Degueldre <sad@odoo.com> | 2020-09-18 11:35:49 +0000 |
| commit | cc8589f74d69816357cb614933358000166fa161 (patch) | |
| tree | deaf1dcb5e677d4efe9360923eb885b3a66ebb43 /addons/web_editor/static/src/js/editor/snippets.options.js | |
| parent | cc4e7f401164acd053864a53372a96873d5d1b77 (diff) | |
[FIX] web_editor: fix color comparison and store normalized colors
Previously, shape colors were stored in non-normalized form (eg, would
use the color's name if it was a palette color), this caused some issues
if you chose a palette color for a shape, then changed the palette: the
wrong color would appear in the color picker because it would look use
the color of the current palette instead of the color that was actually
chosen.
This commit also normalizes the case of color strings before comparing
them, as this was causing some colors to be considered non-default
because of different capitalization.
closes odoo/odoo#58026
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
Diffstat (limited to 'addons/web_editor/static/src/js/editor/snippets.options.js')
| -rw-r--r-- | addons/web_editor/static/src/js/editor/snippets.options.js | 8 |
1 files changed, 4 insertions, 4 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 1a0e8d34935..fe99064abaf 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -3703,7 +3703,7 @@ registry.BackgroundShape = SnippetOptionWidget.extend({ this._handlePreviewState(previewMode, () => { const {colorName} = params; const {colors: previousColors} = this._getShapeData(); - const newColor = widgetValue || this._getDefaultColors()[colorName]; + const newColor = normalizeColor(widgetValue) || this._getDefaultColors()[colorName]; const newColors = Object.assign(previousColors, {[colorName]: newColor}); return {colors: newColors}; }); @@ -3741,7 +3741,7 @@ registry.BackgroundShape = SnippetOptionWidget.extend({ const {shape, colors: customColors} = this._getShapeData(); const colors = Object.assign(this._getDefaultColors(), customColors); const color = shape && colors[params.colorName]; - return color ? normalizeColor(color) : ''; + return color || ''; } case 'flipX': { return this.$target.find('> .o_we_shape.o_we_flip_x').length !== 0; @@ -3869,7 +3869,7 @@ registry.BackgroundShape = SnippetOptionWidget.extend({ const defaultColors = this._getDefaultColors(); const shapeData = Object.assign(this._getShapeData(), newData); const areColorsDefault = Object.entries(shapeData.colors).every(([colorName, colorValue]) => { - return colorValue === defaultColors[colorName]; + return colorValue.toLowerCase() === defaultColors[colorName].toLowerCase(); }); if (areColorsDefault) { delete shapeData.colors; @@ -3902,7 +3902,7 @@ registry.BackgroundShape = SnippetOptionWidget.extend({ } const queryString = Object.entries(colors) .map(([colorName, colorValue]) => { - const encodedCol = encodeURIComponent(normalizeColor(colorValue)); + const encodedCol = encodeURIComponent(colorValue); return `${colorName}=${encodedCol}`; }).join('&'); return `/web_editor/shape/${shape}.svg?${queryString}`; |
