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.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
Use up to date unit in css input scrub (#1654)
Roman Pominove76981bb0be2
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.tsxindex 1eed08fb05..161bdf5697 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@@ -75,17 +75,17 @@ const useScrub = ({useEffect(() => {const inputRefCurrent = inputRef.current;const scrubRefCurrent = scrubRef.current;- const unit = type === "unit" ? valueRef.current.unit : undefined;if (type !== "unit" ||- unit === undefined ||inputRefCurrent === null ||scrubRefCurrent === null) {return;}+ let unit: Unit = "number";+const validateValue = (numericValue: number) => {let value: CssValueInputValue = {type,@@ -128,11 +128,18 @@ const useScrub = ({// Until we have decision do we use key properties for this or not,// on of the solution to get value inside scrub is to use ref and lazy getter.// Getter to avoid recreating scrub on every value change- getInitialValue: () => {+ getInitialValue() {if (valueRef.current.type === "unit") {return valueRef.current.value;}},+ onStart() {+ // for TS+ if (valueRef.current.type !== "unit") {+ return;+ }+ unit = valueRef.current.unit;+ },onValueInput(event) {// Moving focus to container of the input to hide the caret// (it makes text harder to read and may jump around as you scrub)diff --git a/packages/design-system/src/components/primitives/numeric-gesture-control.ts b/packages/design-system/src/components/primitives/numeric-gesture-control.tsindex a345c32eae..8b939cd024 100644--- a/packages/design-system/src/components/primitives/numeric-gesture-control.ts+++ b/packages/design-system/src/components/primitives/numeric-gesture-control.ts@@ -29,6 +29,7 @@ export type NumericScrubOptions = {minValue?: NumericScrubValue;maxValue?: NumericScrubValue;getInitialValue: () => number | undefined;+ onStart?: () => void;getValue?: (state: NumericScrubState,movement: number,@@ -74,6 +75,7 @@ export const numericScrubControl = () => {const {getInitialValue,+ onStart,getValue = getValueDefault,direction = "horizontal",onValueInput,@@ -162,6 +164,8 @@ export const numericScrubControl = (return;}+ onStart?.();+state.value = value;state.timerId = setTimeout(() => {