Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clone monitored state before modifying #8066

Merged
merged 1 commit into from
Aug 23, 2016

Conversation

w33ble
Copy link
Contributor

@w33ble w33ble commented Aug 23, 2016

Closes #8060

The monitor app state module was using toJSON() to compare the state to see if things changed, and it was optionally ignoring props by mutating the state and just setting the value to true.

The problem is that toJSON() only returns the state by reference, so the monitor was mutating the state and breaking the listeners, which was causing the sidebar to collapse when changes were applied.

This PR does a cloneDeep on the output before modifying and comparing the state.

@jbudz
Copy link
Member

jbudz commented Aug 23, 2016

LGTM

1 similar comment
@epixa
Copy link
Contributor

epixa commented Aug 23, 2016

LGTM

@epixa epixa merged commit 63f222d into elastic:4.x Aug 23, 2016
@@ -19,7 +19,7 @@ function stateMonitor(state, defaultState) {
}

function getStatus() {
const currentState = filterState(state.toJSON());
const currentState = filterState(cloneDeep(state.toJSON()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add a comment here which explains the intent? Basically a terser version of this PR's description: "Get a copy of the underlying state's objects instead of the reference returned by toJSON(), because we need to mutate this object, e.g. in filterState."

@cjcenizal
Copy link
Contributor

One small request, looks great to me otherwise :)

@epixa
Copy link
Contributor

epixa commented Aug 23, 2016

Can you create a beta1 blocker issue to track forward porting this to master?

@w33ble
Copy link
Contributor Author

w33ble commented Aug 23, 2016

yussir

EDIT: opened #8068

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants