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: forbid scrubbing css variables (#4340)

Bogdan Chadkin119a36a3cfa6
diff --git a/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx b/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx
index cd00fcb9c3..490ec6dce9 100644
--- a/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx
+++ b/apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx
@@ -345,6 +345,9 @@ export const CssValueInput = ({
...props
}: CssValueInputProps) => {
const value = props.intermediateValue ?? props.value ?? initialValue;
+ const valueRef = useRef(value);
+ valueRef.current = value;
+
// Used to show description
const [highlightedValue, setHighlighedValue] = useState<
StyleValue | undefined
@@ -524,7 +527,15 @@ export const CssValueInput = ({
});
const shouldHandleEvent = useCallback((node: Node) => {
- return suffixRef.current?.contains?.(node) === false;
+ // prevent scrubbing when css variable is selected
+ if (valueRef.current.type === "var") {
+ return false;
+ }
+ // prevent scrubbing when unit select is in use
+ if (suffixRef.current?.contains?.(node)) {
+ return false;
+ }
+ return true;
}, []);
const [scrubRef, inputRef] = useScrub({