Skip to content

Commit

Permalink
Update value default logic
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFarmer committed Mar 5, 2024
1 parent 54e9561 commit e5a9bda
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/controls/NumericControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const createNumericControl = (args: { coerceNumber: (value: number) => nu
uischema,
}: ControlProps & RendererProps) {
const arialLabelWithFallback = label || schema.description || "Value"
const value = data === null || (typeof data === "object" && Object.keys(data as object).length === 0) ? undefined : data as number
const isRequired = required || uischema.options?.required as boolean

const maxStepsWithoutTextInput = 100
Expand All @@ -33,6 +32,7 @@ export const createNumericControl = (args: { coerceNumber: (value: number) => nu
const isLargeStepCount = stepCount && stepCount > maxStepsWithoutTextInput

const initialValue: number | undefined = typeof schema?.default === "number" ? schema.default : minimum
const value = data === undefined ? initialValue : data as number | null

const addonAfter = uischema.options?.addonAfter as string | undefined
const addonBefore = uischema.options?.addonBefore as string | undefined
Expand Down Expand Up @@ -87,7 +87,7 @@ export const createNumericControl = (args: { coerceNumber: (value: number) => nu
}

const slider = <Slider
value={value}
value={value === null ? undefined : value}
defaultValue={initialValue}
min={minimum}
max={maximum}
Expand Down

0 comments on commit e5a9bda

Please sign in to comment.