From 6c5c2c2c946e46c777036443a0b2a68660b4f735 Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Fri, 11 Sep 2015 11:03:59 +0200 Subject: [PATCH] ignore previous node state/flush states on topo change --- client/app/scripts/charts/nodes-chart.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client/app/scripts/charts/nodes-chart.js b/client/app/scripts/charts/nodes-chart.js index 7702b4e10..026a3eb3c 100644 --- a/client/app/scripts/charts/nodes-chart.js +++ b/client/app/scripts/charts/nodes-chart.js @@ -48,11 +48,14 @@ const NodesChart = React.createClass({ }, componentWillReceiveProps: function(nextProps) { - if (nextProps.nodes !== this.props.nodes) { + // wipe node states when showing different topology + if (nextProps.topologyId !== this.props.topologyId) { this.setState({ nodes: {}, edges: {} }); + } + if (nextProps.nodes !== this.props.nodes) { this.updateGraphState(nextProps); } if (this.props.selectedNodeId !== nextProps.selectedNodeId) { @@ -151,13 +154,13 @@ const NodesChart = React.createClass({ ); }, - initNodes: function(topology, prevNodes) { + initNodes: function(topology) { const centerX = this.props.width / 2; const centerY = this.props.height / 2; const nodes = {}; topology.forEach(function(node, id) { - nodes[id] = prevNodes[id] || {}; + nodes[id] = {}; // use cached positions if available _.defaults(nodes[id], {