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