Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 3acba22

Browse files
committed
Ensuring that .valid prop is reset correctly on child fields for RESET_VALIDITY action. Fixes #463
1 parent ef6c114 commit 3acba22

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/reducers/form/reset-validity-action-reducer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ export default function resetValidityActionReducer(state, action, localPath) {
88
}
99

1010
return updateField(state, localPath, {
11+
valid: initialFieldState.valid,
1112
validity: initialFieldState.validity,
1213
errors: initialFieldState.errors,
1314
}, {
15+
valid: initialFieldState.valid,
1416
validity: initialFieldState.validity,
1517
errors: initialFieldState.errors,
1618
});

test/form-reducer-actions-spec.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,41 @@ describe('formReducer() (V1)', () => {
283283
},
284284
},
285285
],
286+
[actionTypes.RESET_VALIDITY]: [
287+
{
288+
action: actions.resetValidity,
289+
model: 'user',
290+
initialState: {
291+
$form: {
292+
...initialFieldState,
293+
valid: false,
294+
validity: { foo: false },
295+
errors: { foo: true },
296+
},
297+
name: {
298+
...initialFieldState,
299+
valid: false,
300+
validity: { required: false },
301+
errors: { required: true },
302+
},
303+
},
304+
expectedField: {
305+
validity: {},
306+
errors: {},
307+
valid: true,
308+
},
309+
expectedForm: {
310+
validity: {},
311+
errors: {},
312+
valid: true,
313+
},
314+
expectedSubField: {
315+
validity: {},
316+
errors: {},
317+
valid: true,
318+
},
319+
},
320+
],
286321
[actionTypes.SET_ERRORS]: [
287322
{
288323
label: '1',

0 commit comments

Comments
 (0)