fix: exception when deleting object with formula fields in sub-form (#4897)

This commit is contained in:
Katherine 2024-07-18 17:53:03 +08:00 committed by GitHub
parent ed937d5f18
commit 22b85677c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -20,7 +20,6 @@ import {
useFormBlockContext,
ActionContext,
} from '@nocobase/client';
import { debounce } from 'lodash';
import { Evaluator, evaluators } from '@nocobase/evaluators/client';
import { Registry, toFixedByStep } from '@nocobase/utils/client';
import React, { useEffect, useState, useContext } from 'react';
@ -74,13 +73,11 @@ export function Result(props) {
const fieldPath = path?.replace(`.${fieldSchema.name}`, '');
const fieldName = fieldPath.split('.')[0];
const index = parseInt(fieldPath.split('.')?.[1]);
const ctx = useContext(ActionContext);
useEffect(() => {
setEditingValue(value);
}, [value]);
useFormEffects(() => {
const delayedOnChange = debounce(props.onChange, 300);
onFormValuesChange((form) => {
if (
(fieldSchema.name as string).indexOf('.') >= 0 ||
@ -102,8 +99,9 @@ export function Result(props) {
setEditingValue(v);
}
setEditingValue(v);
delayedOnChange(v);
ctx?.setFormValueChanged?.(false);
if (v !== field.value) {
field.value = v;
}
});
});
const Component = TypedComponents[dataType] ?? InputString;