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

Commit 326eb16

Browse files
committed
Merge branch 'master' of github.com:davidkpiano/react-redux-form
2 parents bb23082 + a594b34 commit 326eb16

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/reducers/forms-reducer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function createFormCombiner(strategy = defaultStrategy) {
8888
[key]: (state, action) => strategy.formReducer(model, initialFormState, {
8989
plugins,
9090
...formOptions,
91-
})(state, { ...action, state: modelCache[cacheId] }),
91+
})(state, { ...action, state: Object.assign({}, modelCache[cacheId]) }),
9292
};
9393
}
9494

test/model-actions-spec.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { assert } from 'chai';
22
import { combineReducers } from 'redux';
33
import Immutable from 'immutable';
4-
import { actions, modelReducer, formReducer, track, combineForms } from '../src';
4+
import thunk from 'redux-thunk';
5+
import { actions, modelReducer, formReducer, track, combineForms, createForms } from '../src';
56
import {
67
actions as immutableActions,
78
modelReducer as immutableModelReducer,
89
} from '../immutable';
10+
import createTestStore from 'redux-test-store';
11+
12+
import { testCreateStore } from './utils';
913

1014
describe('model actions', () => {
1115
const testItems = [
@@ -112,6 +116,28 @@ describe('model actions', () => {
112116
assert.equal(actual.fooForm.$form.pristine, true);
113117
assert.equal(actual.fooForm.$form.touched, false);
114118
});
119+
120+
it('after load model actions on non-set field should not fail', () => {
121+
const reducer = createForms({
122+
foo: {
123+
bar: '',
124+
},
125+
});
126+
127+
const store = createTestStore(testCreateStore({
128+
...reducer,
129+
}, thunk));
130+
131+
store.dispatch(actions.load('foo', { bar: 'string' }));
132+
const actual = store.getState();
133+
assert.deepEqual(actual.foo, { bar: 'string' });
134+
assert.equal(actual.forms.$form.pristine, true);
135+
assert.equal(actual.forms.$form.touched, false);
136+
137+
138+
store.dispatch(actions.focus('foo.notExist', { silent: true }));
139+
store.dispatch(actions.blur('foo.notExist'));
140+
});
115141
});
116142

117143
describe('change()', () => {

0 commit comments

Comments
 (0)