mirror of
https://github.com/samanhappy/mcphub.git
synced 2025-12-24 02:39:19 -05:00
fix: handle undefined and null values for number inputs in DynamicForm (#261)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -297,7 +297,7 @@ const DynamicForm: React.FC<DynamicFormProps> = ({ schema, onSubmit, onCancel, l
|
|||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
step={schema.type === 'integer' ? '1' : 'any'}
|
step={schema.type === 'integer' ? '1' : 'any'}
|
||||||
value={value || ''}
|
value={value ?? ''}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const val = e.target.value === '' ? '' : schema.type === 'integer' ? parseInt(e.target.value) : parseFloat(e.target.value);
|
const val = e.target.value === '' ? '' : schema.type === 'integer' ? parseInt(e.target.value) : parseFloat(e.target.value);
|
||||||
onChange(val);
|
onChange(val);
|
||||||
@@ -542,7 +542,7 @@ const DynamicForm: React.FC<DynamicFormProps> = ({ schema, onSubmit, onCancel, l
|
|||||||
<input
|
<input
|
||||||
type="number"
|
type="number"
|
||||||
step={propSchema.type === 'integer' ? '1' : 'any'}
|
step={propSchema.type === 'integer' ? '1' : 'any'}
|
||||||
value={value || ''}
|
value={value !== undefined && value !== null ? value : ''}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const val = e.target.value === '' ? '' : propSchema.type === 'integer' ? parseInt(e.target.value) : parseFloat(e.target.value);
|
const val = e.target.value === '' ? '' : propSchema.type === 'integer' ? parseInt(e.target.value) : parseFloat(e.target.value);
|
||||||
handleInputChange(fullPath, val);
|
handleInputChange(fullPath, val);
|
||||||
|
|||||||
Reference in New Issue
Block a user