1- import log from '@tdesign/common-js/log/index' ;
2- import { cloneDeep , get , isEqual , merge , set , unset } from 'lodash-es' ;
31import React , { useEffect , useImperativeHandle , useMemo , useRef , useState } from 'react' ;
2+ import { cloneDeep , get , isEqual , merge , set , unset } from 'lodash-es' ;
3+ import log from '@tdesign/common-js/log/index' ;
44import { FormListContext , useFormContext , useFormListContext } from './FormContext' ;
55import { HOOK_MARK } from './hooks/useForm' ;
66import { calcFieldValue , concatNamePath , normalizeNamePath } from './utils' ;
@@ -26,12 +26,14 @@ const FormList: React.FC<TdFormListProps> = (props) => {
2626 const normalizedName = normalizeNamePath ( name ) ;
2727 const normalizedParentPath = normalizeNamePath ( parentFullPath ) ;
2828 // 如果没有父路径,直接使用 name
29- if ( ! parentFullPath || normalizedParentPath . length === 0 ) {
29+ if ( normalizedParentPath . length === 0 ) {
3030 return normalizedName ;
3131 }
3232 // 检查 name 是否已经包含了完整的父路径
3333 // 兼容场景:https://github.com/Tencent/tdesign-react/issues/3843
34- const isAbsolutePath = normalizedParentPath . every ( ( segment , index ) => normalizedName [ index ] === segment ) ;
34+ const isAbsolutePath =
35+ normalizedName . length >= normalizedParentPath . length &&
36+ normalizedParentPath . every ( ( segment , index ) => normalizedName [ index ] === segment ) ;
3537 if ( isAbsolutePath ) return normalizedName ;
3638 // 如果是相对路径,与父路径拼接
3739 return concatNamePath ( parentFullPath , name ) ;
@@ -263,7 +265,7 @@ const FormList: React.FC<TdFormListProps> = (props) => {
263265 setFormListValue ( data ) ;
264266 const newFields = data ?. map ( ( data , index ) => ( {
265267 data : { ...data } ,
266- key : ( globalKey += 1 ) ,
268+ key : ( globalKey += 1 ) ,
267269 name : index ,
268270 isListField : true ,
269271 } ) ) ;
0 commit comments