diff --git a/superset-frontend/spec/javascripts/explore/exploreActions_spec.js b/superset-frontend/spec/javascripts/explore/exploreActions_spec.js index b0ab99da5ae..43158dfa788 100644 --- a/superset-frontend/spec/javascripts/explore/exploreActions_spec.js +++ b/superset-frontend/spec/javascripts/explore/exploreActions_spec.js @@ -28,6 +28,7 @@ describe('reducers', () => { actions.setControlValue('x_axis_label', 'x', []), ); expect(newState.controls.x_axis_label.value).toBe('x'); + expect(newState.form_data.x_axis_label).toBe('x'); }); it('setControlValue works as expected with a checkbox', () => { const newState = exploreReducer( @@ -35,5 +36,6 @@ describe('reducers', () => { actions.setControlValue('show_legend', true, []), ); expect(newState.controls.show_legend.value).toBe(true); + expect(newState.form_data.show_legend).toBe(true); }); }); diff --git a/superset-frontend/src/explore/reducers/exploreReducer.js b/superset-frontend/src/explore/reducers/exploreReducer.js index c837b987cf4..de95ef4b95e 100644 --- a/superset-frontend/src/explore/reducers/exploreReducer.js +++ b/superset-frontend/src/explore/reducers/exploreReducer.js @@ -94,12 +94,8 @@ export default function exploreReducer(state = {}, action) { }; }, [actions.SET_FIELD_VALUE]() { - let new_form_data = state.form_data; - if (action.controlName === 'viz_type') { - new_form_data = JSON.parse(JSON.stringify(new_form_data)); - // Update state's vizType if we are switching to a new visualization - new_form_data.viz_type = action.value; - } + const new_form_data = state.form_data; + new_form_data[action.controlName] = action.value; // These errors are reported from the Control components let errors = action.validationErrors || [];