fix(plugin-sequence): avoid invalid value from ArrayTable.useRecord() (#2859)

This commit is contained in:
Junyi 2023-10-18 11:56:57 +08:00 committed by GitHub
parent e920629a91
commit d3bf9a7a4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,9 +40,11 @@ function RuleTypeSelect(props) {
}
function RuleOptions() {
const { type, options } = ArrayTable.useRecord();
const ruleType = RuleTypes[type];
const compile = useCompile();
const { values } = useForm();
const index = ArrayTable.useIndex();
const { type, options } = values.patterns[index];
const ruleType = RuleTypes[type];
return (
<div
className={css`
@ -210,9 +212,9 @@ export function RuleConfigForm() {
const { t } = useTranslation();
const compile = useCompile();
const schemaOptions = useContext(SchemaOptionsContext);
const form = useForm();
const { type, options } = ArrayTable.useRecord();
const { values, setValuesIn } = useForm();
const index = ArrayTable.useIndex();
const { type, options } = values.patterns[index];
const ruleType = RuleTypes[type];
return ruleType?.fieldset ? (
<Button
@ -252,7 +254,7 @@ export function RuleConfigForm() {
initialValues: options,
})
.then((values) => {
form.setValuesIn(`patterns.${index}`, { type, options: { ...values } });
setValuesIn(`patterns.${index}`, { type, options: { ...values } });
})
.catch((err) => {
error(err);