fix(plugin-sequence): avoid invalid value from ArrayTable.useRecord() (#2859)
				
					
				
			This commit is contained in:
		
							parent
							
								
									e920629a91
								
							
						
					
					
						commit
						d3bf9a7a4d
					
				@ -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);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user