diff --git a/packages/table/src/utils/cellRenderToFromItem.tsx b/packages/table/src/utils/cellRenderToFromItem.tsx index ab74cd245917..399825e96989 100644 --- a/packages/table/src/utils/cellRenderToFromItem.tsx +++ b/packages/table/src/utils/cellRenderToFromItem.tsx @@ -1,11 +1,6 @@ import type { ProFieldEmptyText } from '@ant-design/pro-field'; import type { ProFormFieldProps } from '@ant-design/pro-form'; -import { - FieldContext, - ProForm, - ProFormDependency, - ProFormField, -} from '@ant-design/pro-form'; +import { FieldContext, ProForm, ProFormField } from '@ant-design/pro-form'; import type { ProFieldValueType, ProSchemaComponentTypes, @@ -16,6 +11,8 @@ import { InlineErrorFormItem, runFunction, } from '@ant-design/pro-utils'; +import { Form } from 'antd'; +import get from 'rc-util/lib/utils/get'; import React, { useCallback, useContext, @@ -237,9 +234,23 @@ const CellRenderFromItem = (props: CellRenderFromItemProps) => { typeof columnProps?.formItemProps === 'function' ) { return ( - + { + if (pre === next) return false; + const shouldName = [rowName].flat(1); + try { + return ( + JSON.stringify(get(pre, shouldName)) !== + JSON.stringify(get(next, shouldName)) + ); + } catch (error) { + return true; + } + }} + > {() => generateFormItem()} - + ); } return generateFormItem(); diff --git a/packages/utils/src/components/InlineErrorFormItem/index.tsx b/packages/utils/src/components/InlineErrorFormItem/index.tsx index 99e6ff81ea1d..e24cb6aa7456 100644 --- a/packages/utils/src/components/InlineErrorFormItem/index.tsx +++ b/packages/utils/src/components/InlineErrorFormItem/index.tsx @@ -94,10 +94,15 @@ const InternalFormItemFunction: React.FC = ({ rules={rules} hasFeedback={false} shouldUpdate={(prev, next) => { + if (prev === next) return false; + const shouldName = [name].flat(1); + if (shouldName.length > 1) { + shouldName.pop(); + } try { return ( - JSON.stringify(get(prev, [name].flat(1))) !== - JSON.stringify(get(next, [name].flat(1))) + JSON.stringify(get(prev, shouldName)) !== + JSON.stringify(get(next, shouldName)) ); } catch (error) { return true; @@ -155,10 +160,15 @@ export const InlineErrorFormItem = (props: InlineErrorFormItemProps) => { shouldUpdate={ name ? (prev, next) => { + if (prev === next) return false; + const shouldName = [name].flat(1); + if (shouldName.length > 1) { + shouldName.pop(); + } try { return ( - JSON.stringify(get(prev, [name].flat(1))) !== - JSON.stringify(get(next, [name].flat(1))) + JSON.stringify(get(prev, shouldName)) !== + JSON.stringify(get(next, shouldName)) ); } catch (error) { return true;