File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export default function useFormItemInitialData(
2828
2929 const defaultInitialData = getDefaultInitialData ( children , initialData ) ;
3030
31- // 优先级:floatFormData > FormItem.initialData > FormList.initialData > Form.initialData
31+ // 优先级:floatFormData > store > FormItem.initialData > FormList.initialData > Form.initialData
3232 function getDefaultInitialData ( children : FormItemProps [ 'children' ] , initialData : FormItemProps [ 'initialData' ] ) {
3333 if ( name && floatingFormDataRef ?. current && ! isEmpty ( floatingFormDataRef . current ) ) {
3434 const nameList = formListName ? [ formListName , name ] . flat ( ) : name ;
@@ -40,11 +40,19 @@ export default function useFormItemInitialData(
4040 }
4141 }
4242
43+ const isFormList = formListName && Array . isArray ( fullPath ) ;
44+
4345 if ( typeof initialData !== 'undefined' ) {
46+ if ( isFormList ) {
47+ const storeValue = get ( form . store , fullPath ) ;
48+ if ( typeof storeValue !== 'undefined' ) {
49+ return storeValue ;
50+ }
51+ }
4452 return initialData ;
4553 }
4654
47- if ( formListName && Array . isArray ( fullPath ) ) {
55+ if ( isFormList ) {
4856 const pathPrefix = fullPath . slice ( 0 , - 1 ) ;
4957 const pathExisted = has ( form . store , pathPrefix ) ;
5058 if ( pathExisted ) {
Original file line number Diff line number Diff line change 1+ ---
2+ pr_number : 4201
3+ contributor : RylanBot
4+ ---
5+
6+ - fix(Form): 修复 ` initialData ` 覆盖 ` setFieldsValue ` 设置值的问题 @RylanBot ([ #4201 ] ( https://github.com/Tencent/tdesign-react/pull/4201 ) )
You can’t perform that action at this time.
0 commit comments