diff --git a/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-size.tsx b/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-size.tsx index d2fc185d1c..ebc0041dbb 100644 --- a/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-size.tsx +++ b/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-size.tsx @@ -59,13 +59,13 @@ export const BackgroundSize = ({ index }: { index: number }) => { }; const setValueX: SetValue = (value, options) => { - const [x] = value.type === "layers" ? value.value : []; + const [x] = value.type === "layers" ? value.value : [value]; const nextValue = toTuple(x, customSizeValue.value[1]); setValue(nextValue, options); }; const setValueY: SetValue = (value, options) => { - const [y] = value.type === "layers" ? value.value : []; + const [y] = value.type === "layers" ? value.value : [value]; const nextValue = toTuple(customSizeValue.value[0], y); setValue(nextValue, options); }; diff --git a/apps/builder/app/builder/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.ts b/apps/builder/app/builder/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.ts index 3970920d52..97fb16de83 100644 --- a/apps/builder/app/builder/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.ts +++ b/apps/builder/app/builder/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.ts @@ -44,6 +44,13 @@ export const parseIntermediateOrInvalidValue = ( } if ("unit" in styleValue && styleValue.unit === "number") { + // when unit is number some properties supports only integer + // for example z-index + styleInput = parseCssValue(property, `${Math.round(Number(value))}`); + if (styleInput.type !== "invalid") { + return styleInput; + } + // Most css props supports 0 as unitless value, but not other numbers. // Its possible that we had { value: 0, unit: "number" } and value has changed // Lets try to parse it as px value diff --git a/apps/builder/app/builder/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.ts.test.ts b/apps/builder/app/builder/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.ts.test.ts index f9df497829..74b0e71d80 100644 --- a/apps/builder/app/builder/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.ts.test.ts +++ b/apps/builder/app/builder/features/style-panel/shared/css-value-input/parse-intermediate-or-invalid-value.ts.test.ts @@ -606,3 +606,17 @@ test("parse css variables as unparsed", () => { value: "url(https://my-image.com)", }); }); + +test("parse z-index", () => { + expect( + parseIntermediateOrInvalidValue("zIndex", { + type: "intermediate", + value: "6.5", + unit: "number", + }) + ).toEqual({ + type: "unit", + value: 7, + unit: "number", + }); +});