File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -500,7 +500,7 @@ export class FormStore {
500
500
const mergedPreserve = preserve !== undefined ? preserve : this . preserve ;
501
501
if ( mergedPreserve === false && ! isListField ) {
502
502
const namePath = entity . getNamePath ( ) ;
503
- if ( this . getFieldValue ( namePath ) !== undefined ) {
503
+ if ( namePath . length && this . getFieldValue ( namePath ) !== undefined ) {
504
504
this . store = setValue ( this . store , namePath , undefined ) ;
505
505
}
506
506
}
Original file line number Diff line number Diff line change @@ -137,5 +137,35 @@ describe('Form.Preserve', () => {
137
137
138
138
errorSpy . mockRestore ( ) ;
139
139
} ) ;
140
+
141
+ it ( 'nest render props should not clean full store' , ( ) => {
142
+ let form : FormInstance ;
143
+
144
+ const wrapper = mount (
145
+ < Form
146
+ preserve = { false }
147
+ ref = { instance => {
148
+ form = instance ;
149
+ } }
150
+ >
151
+ < Form . Field name = "light" >
152
+ < input />
153
+ </ Form . Field >
154
+ < Form . Field shouldUpdate >
155
+ { ( _ , __ , { getFieldValue } ) =>
156
+ getFieldValue ( 'light' ) === 'bamboo' ? < Form . Field > { ( ) => null } </ Form . Field > : null
157
+ }
158
+ </ Form . Field >
159
+ </ Form > ,
160
+ ) ;
161
+
162
+ wrapper . find ( 'input' ) . simulate ( 'change' , { target : { value : 'bamboo' } } ) ;
163
+ expect ( form . getFieldsValue ( ) ) . toEqual ( { light : 'bamboo' } ) ;
164
+
165
+ wrapper . find ( 'input' ) . simulate ( 'change' , { target : { value : 'little' } } ) ;
166
+ expect ( form . getFieldsValue ( ) ) . toEqual ( { light : 'little' } ) ;
167
+
168
+ wrapper . unmount ( ) ;
169
+ } ) ;
140
170
} ) ;
141
171
/* eslint-enable no-template-curly-in-string */
You can’t perform that action at this time.
0 commit comments