Merge branch 'feat/ui-0.5.0' into 'test'

fix(ui): solve the problem that the checkbox cannot be selected

See merge request opensource/answer!292
This commit is contained in:
Li Shuailing 2022-11-29 09:21:25 +00:00
commit 854d40e55a
3 changed files with 22 additions and 3 deletions

View File

@ -24,7 +24,7 @@ const Index: FC<Props> = ({
showTagUrlSlug: true,
},
}) => {
if (!newData?.original_text) return null;
if (!newData) return null;
let tag = newData.tags;
if (objectType === 'question' && oldData?.tags) {

View File

@ -237,6 +237,24 @@ const SchemaForm: FC<IProps> = ({
}
};
const handleCheckboxChange = (
e: React.ChangeEvent<HTMLInputElement>,
index: number,
) => {
const { name } = e.target;
const data = {
...formData,
[name]: {
...formData[name],
value: schema.properties[name]?.enum?.[index],
isInvalid: false,
},
};
if (onChange instanceof Function) {
onChange(data);
}
};
return (
<Form noValidate onSubmit={handleSubmit}>
{keys.map((key) => {
@ -280,13 +298,14 @@ const SchemaForm: FC<IProps> = ({
inline
required
type={widget}
name={title}
name={key}
id={String(item)}
label={properties[key].enumNames?.[index]}
checked={formData[key]?.value === item}
feedback={formData[key]?.errorMsg}
feedbackType="invalid"
isInvalid={formData[key].isInvalid}
onChange={(e) => handleCheckboxChange(e, index)}
/>
);
})}

View File

@ -37,7 +37,7 @@ const Smtp: FC = () => {
type: 'boolean',
title: t('encryption.label'),
description: t('encryption.text'),
enum: [true, false],
enum: ['SSL', ''],
enumNames: ['SSL', ''],
},
smtp_port: {