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 19694e8de5022..f4ac0b1d5957f 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -1313,16 +1313,26 @@ const InputUserValueWidget = UnitUserValueWidget.extend({ case $.ui.keyCode.UP: case $.ui.keyCode.DOWN: { const input = ev.currentTarget; - let value = parseFloat(input.value || input.placeholder); - if (isNaN(value)) { - value = 0.0; + let parts = (input.value || input.placeholder).match(/-?\d+\.\d+|-?\d+/g); + if (!parts) { + parts = [input.value || input.placeholder]; } - let step = parseFloat(params.step); - if (isNaN(step)) { - step = 1.0; - } - value += (ev.which === $.ui.keyCode.UP ? step : -step); - input.value = this._floatToStr(value); + input.value = parts.map(part => { + let value = parseFloat(part); + if (isNaN(value)) { + value = 0.0; + } + let step = parseFloat(params.step); + if (isNaN(step)) { + step = 1.0; + } + value += (ev.which === $.ui.keyCode.UP ? step : -step); + if (parts.length > 1 && value < 0) { + // No negative for composite values. + value = 0.0; + } + return this._floatToStr(value); + }).join(" "); // We need to know if the change event will be triggered or not. // Change is triggered if there has been a "natural" input event // from the user. Since we are triggering a "fake" input event,