From e1163975b507ad10e20865ee3f75e7006e7fd413 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Fri, 2 Jun 2017 17:09:28 +0300 Subject: [PATCH 1/2] Fixed resolveModel context propagation issues --- src/components/control-component.js | 7 ------ src/utils/resolve-model.js | 21 ++++++----------- test/model-resolving-spec.js | 36 +++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/components/control-component.js b/src/components/control-component.js index f5c5e9ab2..a9f8b0804 100644 --- a/src/components/control-component.js +++ b/src/components/control-component.js @@ -668,13 +668,6 @@ function createControlClass(s = defaultStrategy) { /* eslint-disable react/prop-types */ /* eslint-disable react/no-multi-comp */ class DefaultConnectedControl extends React.Component { - shouldComponentUpdate(nextProps) { - return !shallowEqual(this.props, nextProps, { - deepKeys: ['controlProps'], - omitKeys: ['mapProps'], - }); - } - render() { return ( ); } } diff --git a/test/model-resolving-spec.js b/test/model-resolving-spec.js index 690910990..9570dc6ae 100644 --- a/test/model-resolving-spec.js +++ b/test/model-resolving-spec.js @@ -195,4 +195,40 @@ describe('model resolving', () => { assert.equal(controlInput.value, 'control value'); }); }); + + it('deep resolves with dynamic model', () => { + const deepInitialState = { + foo: { value: 'fooValue' }, + bar: { value: 'barValue' }, + }; + + const deepStore = testCreateStore({ + test: modelReducer('test', deepInitialState), + testForm: formReducer('test', deepInitialState), + }); + + class DynamicSubform extends React.Component { + state = { model: '.foo' }; + render() { + return ( +
+
+ ); + } + } + + const app = testRender( +
+ + , deepStore); + + const input = TestUtils.findRenderedDOMComponentWithTag(app, 'input'); + const button = TestUtils.findRenderedDOMComponentWithTag(app, 'button'); + + assert.equal(input.value, 'fooValue'); + TestUtils.Simulate.click(button); + assert.equal(input.value, 'barValue'); + }); }); From f002ef2510818c546d42d5aa768a921afb3b6869 Mon Sep 17 00:00:00 2001 From: Dmitry Kabak Date: Wed, 7 Jun 2017 12:27:47 +0300 Subject: [PATCH 2/2] Added back shouldComponentUpdate in DefaultConnectedControl --- src/components/control-component.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/control-component.js b/src/components/control-component.js index a9f8b0804..da543d5d5 100644 --- a/src/components/control-component.js +++ b/src/components/control-component.js @@ -668,6 +668,13 @@ function createControlClass(s = defaultStrategy) { /* eslint-disable react/prop-types */ /* eslint-disable react/no-multi-comp */ class DefaultConnectedControl extends React.Component { + shouldComponentUpdate(nextProps, nextState, nextContext) { + return !shallowEqual(this.context, nextContext) || !shallowEqual(this.props, nextProps, { + deepKeys: ['controlProps'], + omitKeys: ['mapProps'], + }); + } + render() { return (