mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:38:13 +00:00
fix: exception when deleting object with formula fields in sub-form (#4897)
This commit is contained in:
parent
ed937d5f18
commit
22b85677c3
@ -20,7 +20,6 @@ import {
|
|||||||
useFormBlockContext,
|
useFormBlockContext,
|
||||||
ActionContext,
|
ActionContext,
|
||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
import { debounce } from 'lodash';
|
|
||||||
import { Evaluator, evaluators } from '@nocobase/evaluators/client';
|
import { Evaluator, evaluators } from '@nocobase/evaluators/client';
|
||||||
import { Registry, toFixedByStep } from '@nocobase/utils/client';
|
import { Registry, toFixedByStep } from '@nocobase/utils/client';
|
||||||
import React, { useEffect, useState, useContext } from 'react';
|
import React, { useEffect, useState, useContext } from 'react';
|
||||||
@ -74,13 +73,11 @@ export function Result(props) {
|
|||||||
const fieldPath = path?.replace(`.${fieldSchema.name}`, '');
|
const fieldPath = path?.replace(`.${fieldSchema.name}`, '');
|
||||||
const fieldName = fieldPath.split('.')[0];
|
const fieldName = fieldPath.split('.')[0];
|
||||||
const index = parseInt(fieldPath.split('.')?.[1]);
|
const index = parseInt(fieldPath.split('.')?.[1]);
|
||||||
const ctx = useContext(ActionContext);
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setEditingValue(value);
|
setEditingValue(value);
|
||||||
}, [value]);
|
}, [value]);
|
||||||
|
|
||||||
useFormEffects(() => {
|
useFormEffects(() => {
|
||||||
const delayedOnChange = debounce(props.onChange, 300);
|
|
||||||
onFormValuesChange((form) => {
|
onFormValuesChange((form) => {
|
||||||
if (
|
if (
|
||||||
(fieldSchema.name as string).indexOf('.') >= 0 ||
|
(fieldSchema.name as string).indexOf('.') >= 0 ||
|
||||||
@ -102,8 +99,9 @@ export function Result(props) {
|
|||||||
setEditingValue(v);
|
setEditingValue(v);
|
||||||
}
|
}
|
||||||
setEditingValue(v);
|
setEditingValue(v);
|
||||||
delayedOnChange(v);
|
if (v !== field.value) {
|
||||||
ctx?.setFormValueChanged?.(false);
|
field.value = v;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const Component = TypedComponents[dataType] ?? InputString;
|
const Component = TypedComponents[dataType] ?? InputString;
|
||||||
|
Loading…
Reference in New Issue
Block a user