From 14c0550b292bb6ed5ed63d5fd94319904c82e7db Mon Sep 17 00:00:00 2001 From: Thanh Dodeur Date: Fri, 6 Mar 2020 11:10:13 +0000 Subject: [PATCH] [FIX] web_editor: fixes the rgb/rgba color selection Before this commit, `selectStyle` could incorrectly split the widgetValue (as described below) which resulted in invalid CSS. widgetValue: `"rgba(55, 12, 99, 0.7) 55px"` result: `["rgba(55,", "12,", "99,", "0.7)", "55px"]` expected: `["rgba(55, 12, 99, 0.7)", "55px"]` fixed: `["rgba(55,12,99,0.7)", "55px"]` This commit fixes the issue. closes odoo/odoo#47515 X-original-commit: 37e6b87341e58769ec2c1d080986e84286d84978 Signed-off-by: Quentin Smetz (qsm) --- addons/web_editor/static/src/js/editor/snippets.options.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 9586cd2d361..15d22959efb 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -1607,7 +1607,9 @@ const SnippetOptionWidget = Widget.extend({ widgetValue = `var(--${widgetValue})`; } - const values = widgetValue.split(/\s+/g); + // replacing ', ' by ',' to prevent attributes with internal space separators from being split: + // eg: "rgba(55, 12, 47, 1.9) 47px" should be split as ["rgba(55,12,47,1.9)", "47px"] + const values = widgetValue.replace(/,\s/g, ',').split(/\s+/g); while (values.length < cssProps.length) { switch (values.length) { case 1: