Skip to content

Commit cc1567a

Browse files
committed
fix: Fix incorrect default value when the input type is number in SchemeForm.
1 parent f403ead commit cc1567a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,16 @@ const Index: FC<Props> = ({
7373
}
7474
};
7575

76+
// For number type, use ?? to preserve 0 value; for other types, use || for backward compatibility
77+
const inputValue =
78+
type === 'number' ? (fieldObject?.value ?? '') : fieldObject?.value || '';
79+
7680
return (
7781
<Form.Control
7882
name={fieldName}
7983
placeholder={placeholder}
8084
type={type}
81-
value={fieldObject?.value || ''}
85+
value={inputValue}
8286
{...numberInputProps}
8387
inputMode={inputMode}
8488
onChange={handleChange}

ui/src/pages/Admin/QaSettings/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const QaSettings = () => {
4949
type: 'number',
5050
title: t('min_tags.label'),
5151
description: t('min_tags.text'),
52+
default: 0,
5253
},
5354
min_content: {
5455
type: 'number',
@@ -124,6 +125,7 @@ const QaSettings = () => {
124125
formMeta.min_tags.value = res.min_tags;
125126
formMeta.min_content.value = res.min_content;
126127
formMeta.restrict_answer.value = res.restrict_answer;
128+
console.log('res', res, formMeta);
127129
setFormData(formMeta);
128130
}
129131
});

0 commit comments

Comments
 (0)