Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix: ignore transparent color when paste gradient (#3736)

Bogdan Chadkined05084db4de
diff --git a/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-gradient.tsx b/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-gradient.tsx
index ecf29ede7f..47a641a016 100644
--- a/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-gradient.tsx
+++ b/apps/builder/app/builder/features/style-panel/sections/backgrounds/background-gradient.tsx
@@ -16,6 +16,9 @@ type IntermediateValue = {
value: string;
};
+const isTransparent = (color: StyleValue) =>
+ color.type === "keyword" && color.value === "transparent";
+
export const BackgroundGradient = (
props: Omit<ControlProps, "property" | "items"> & {
setBackgroundColor: (color: StyleValue) => void;
@@ -73,8 +76,7 @@ export const BackgroundGradient = (
// set invalid state
if (
- backgroundColor === undefined ||
- backgroundColor.type === "invalid" ||
+ backgroundColor?.type === "invalid" ||
layer === undefined ||
layer.type === "invalid"
) {
@@ -82,8 +84,10 @@ export const BackgroundGradient = (
props.deleteProperty(property, { isEphemeral: true });
return;
}
- props.setBackgroundColor(backgroundColor);
setIntermediateValue(undefined);
+ if (backgroundColor && isTransparent(backgroundColor) === false) {
+ props.setBackgroundColor(backgroundColor);
+ }
props.setProperty(property)(layer);
};