Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix: Fix incorrect default value when the input type is number in SchemeForm.

shuaicc1567ac4ba4
diff --git a/ui/src/components/SchemaForm/components/Input.tsx b/ui/src/components/SchemaForm/components/Input.tsx
index a1838151..2f062b61 100644
--- a/ui/src/components/SchemaForm/components/Input.tsx
+++ b/ui/src/components/SchemaForm/components/Input.tsx
@@ -73,12 +73,16 @@ const Index: FC<Props> = ({
}
};
+ // For number type, use ?? to preserve 0 value; for other types, use || for backward compatibility
+ const inputValue =
+ type === 'number' ? (fieldObject?.value ?? '') : fieldObject?.value || '';
+
return (
<Form.Control
name={fieldName}
placeholder={placeholder}
type={type}
- value={fieldObject?.value || ''}
+ value={inputValue}
{...numberInputProps}
inputMode={inputMode}
onChange={handleChange}
diff --git a/ui/src/pages/Admin/QaSettings/index.tsx b/ui/src/pages/Admin/QaSettings/index.tsx
index 17834ab0..67685ba8 100644
--- a/ui/src/pages/Admin/QaSettings/index.tsx
+++ b/ui/src/pages/Admin/QaSettings/index.tsx
@@ -49,6 +49,7 @@ const QaSettings = () => {
type: 'number',
title: t('min_tags.label'),
description: t('min_tags.text'),
+ default: 0,
},
min_content: {
type: 'number',
@@ -124,6 +125,7 @@ const QaSettings = () => {
formMeta.min_tags.value = res.min_tags;
formMeta.min_content.value = res.min_content;
formMeta.restrict_answer.value = res.restrict_answer;
+ console.log('res', res, formMeta);
setFormData(formMeta);
}
});