diff --git a/editor/src/components/inspector/flex-section.tsx b/editor/src/components/inspector/flex-section.tsx index 3ff686593e13..b32f4da14128 100644 --- a/editor/src/components/inspector/flex-section.tsx +++ b/editor/src/components/inspector/flex-section.tsx @@ -887,6 +887,8 @@ const GapRowColumnControl = React.memo(() => { { { { testId='flex.container.gap' key='flex.container.gap' value={value} + minimum={0} + clampOnSubmitValue={true} onSubmitValue={wrappedOnSubmitValue} onTransientSubmitValue={wrappedOnTransientSubmitValue} onForcedSubmitValue={wrappedOnSubmitValue} diff --git a/editor/src/uuiui/inputs/number-input.tsx b/editor/src/uuiui/inputs/number-input.tsx index 41db6078d683..aeb9d054fee5 100644 --- a/editor/src/uuiui/inputs/number-input.tsx +++ b/editor/src/uuiui/inputs/number-input.tsx @@ -36,11 +36,10 @@ import type { } from '../../components/inspector/controls/control' import type { Either } from '../../core/shared/either' import { isLeft, mapEither } from '../../core/shared/either' -import { clampValue, point } from '../../core/shared/math-utils' +import { clampValue } from '../../core/shared/math-utils' import { memoize } from '../../core/shared/memoize' import type { ControlStyles } from '../../uuiui-deps' import { getControlStyles, CSSCursor } from '../../uuiui-deps' -import type { IcnProps } from '../icn' import { Icn } from '../icn' import { useColorTheme, UtopiaTheme } from '../styles/theme' import { FlexRow } from '../widgets/layout/flex-row' @@ -141,6 +140,7 @@ export interface NumberInputOptions { pasteHandler?: boolean descriptionLabel?: string disableScrubbing?: boolean + clampOnSubmitValue?: boolean } export interface AbstractNumberInputProps @@ -190,6 +190,7 @@ export const NumberInput = React.memo( invalid, pasteHandler, disableScrubbing = false, + clampOnSubmitValue, }) => { const ref = React.useRef(null) const colorTheme = useColorTheme() @@ -511,7 +512,12 @@ export const NumberInput = React.memo( if (isLeft(parsed)) { return unknownInputValue(displayValue) } - return parsed.value + return clampOnSubmitValue + ? { + ...parsed.value, + value: clampValue(parsed.value.value, minimum, maximum), + } + : parsed.value } const newValue = getNewValue() @@ -540,6 +546,9 @@ export const NumberInput = React.memo( updateValue, value, displayValue, + minimum, + maximum, + clampOnSubmitValue, ], )