Bug 1328567 - TreeView expandedNodes should update when props changed r?honza draft
authorRicky Chien <rchien@mozilla.com>
Wed, 04 Jan 2017 18:13:00 +0800
changeset 456000 ab7646b4516fe2c6ba017eaf90a6761ebffb08ee
parent 455536 57ac9f63fc6953f4efeb0cc84a60192d3721251f
child 541085 323771788f13faa581fae29a0419188e333bbb67
push id40341
push userbmo:rchien@mozilla.com
push dateWed, 04 Jan 2017 16:32:32 +0000
reviewershonza
bugs1328567
milestone53.0a1
Bug 1328567 - TreeView expandedNodes should update when props changed r?honza MozReview-Commit-ID: FdJWqTY52eW
devtools/client/shared/components/tree/tree-view.js
--- a/devtools/client/shared/components/tree/tree-view.js
+++ b/devtools/client/shared/components/tree/tree-view.js
@@ -120,16 +120,23 @@ define(function (require, exports, modul
 
     getInitialState: function () {
       return {
         expandedNodes: this.props.expandedNodes,
         columns: ensureDefaultColumn(this.props.columns)
       };
     },
 
+    componentWillReceiveProps: function (nextProps) {
+      let { expandedNodes } = nextProps;
+      this.setState(Object.assign({}, this.state, {
+        expandedNodes,
+      }));
+    },
+
     // Node expand/collapse
 
     toggle: function (nodePath) {
       let nodes = this.state.expandedNodes;
       if (this.isExpanded(nodePath)) {
         nodes.delete(nodePath);
       } else {
         nodes.add(nodePath);