Fix/http node timeout validation#23077 (#23117)
Co-authored-by: crazywoola <427733928@qq.com>
This commit is contained in:
@@ -20,7 +20,7 @@ const InputField: FC<{
|
|||||||
description: string
|
description: string
|
||||||
placeholder: string
|
placeholder: string
|
||||||
value?: number
|
value?: number
|
||||||
onChange: (value: number) => void
|
onChange: (value: number | undefined) => void
|
||||||
readOnly?: boolean
|
readOnly?: boolean
|
||||||
min: number
|
min: number
|
||||||
max: number
|
max: number
|
||||||
@@ -35,8 +35,18 @@ const InputField: FC<{
|
|||||||
type='number'
|
type='number'
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const value = Math.max(min, Math.min(max, Number.parseInt(e.target.value, 10)))
|
const inputValue = e.target.value
|
||||||
|
if (inputValue === '') {
|
||||||
|
// When user clears the input, set to undefined to let backend use default values
|
||||||
|
onChange(undefined)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const parsedValue = Number.parseInt(inputValue, 10)
|
||||||
|
if (!Number.isNaN(parsedValue)) {
|
||||||
|
const value = Math.max(min, Math.min(max, parsedValue))
|
||||||
onChange(value)
|
onChange(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
|
Reference in New Issue
Block a user