Skip to content

Commit 119a36a

Browse files
authored
fix: forbid scrubbing css variables (#4340)
Css variables takes a lot of space inside of input and user need to have text selection work natively. Scrub does not fit in this.
1 parent 54f6c1c commit 119a36a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

apps/builder/app/builder/features/style-panel/shared/css-value-input/css-value-input.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ export const CssValueInput = ({
345345
...props
346346
}: CssValueInputProps) => {
347347
const value = props.intermediateValue ?? props.value ?? initialValue;
348+
const valueRef = useRef(value);
349+
valueRef.current = value;
350+
348351
// Used to show description
349352
const [highlightedValue, setHighlighedValue] = useState<
350353
StyleValue | undefined
@@ -524,7 +527,15 @@ export const CssValueInput = ({
524527
});
525528

526529
const shouldHandleEvent = useCallback((node: Node) => {
527-
return suffixRef.current?.contains?.(node) === false;
530+
// prevent scrubbing when css variable is selected
531+
if (valueRef.current.type === "var") {
532+
return false;
533+
}
534+
// prevent scrubbing when unit select is in use
535+
if (suffixRef.current?.contains?.(node)) {
536+
return false;
537+
}
538+
return true;
528539
}, []);
529540

530541
const [scrubRef, inputRef] = useScrub({

0 commit comments

Comments
 (0)