Skip to content

Commit 27cd773

Browse files
Dinesht04LinkinStars
authored andcommitted
fix(ui): refactor number input props (min,max)
1 parent 1418745 commit 27cd773

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

ui/src/components/SchemaForm/components/Input.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@ const Index: FC<Props> = ({
5050
formData,
5151
readOnly = false,
5252
min = 0,
53-
max = 65355,
53+
max,
5454
inputMode = 'text',
5555
}) => {
5656
const fieldObject = formData[fieldName];
57+
const numberInputProps =
58+
type === 'number'
59+
? { min, ...(max != null && max > 0 ? { max } : {}) }
60+
: {};
5761
const handleChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
5862
const { name, value } = evt.currentTarget;
5963
const state = {
@@ -75,8 +79,7 @@ const Index: FC<Props> = ({
7579
placeholder={placeholder}
7680
type={type}
7781
value={fieldObject?.value || ''}
78-
min={min}
79-
max={max}
82+
{...numberInputProps}
8083
inputMode={inputMode}
8184
onChange={handleChange}
8285
disabled={readOnly}

ui/src/components/SchemaForm/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ const SchemaForm: ForwardRefRenderFunction<FormRef, FormProps> = (
260260
enum: enumValues = [],
261261
enumNames = [],
262262
max_length = 0,
263-
max = 65355,
263+
max,
264264
min = 0,
265265
} = properties[key];
266266
const { 'ui:widget': widget = 'input', 'ui:options': uiOpt } =

0 commit comments

Comments
 (0)