Bug 1328008 - Stop collapsing TreeView nodes when clicking a value. r=Honza
authorOriol Brufau <oriol-bugzilla@hotmail.com>
Wed, 30 Aug 2017 07:27:00 -0400
changeset 377984 383c01a3dcb0ae317a5f2464c5e35f45d592dc45
parent 377983 6c8a5a8f95aa7b06fea7e7c9d6c4426147f1038d
child 377985 d7c36348c05b4634d7f5ade63470fd6962f141f2
child 378041 14eea6bedcf3e2f46ea7c908e1ac9b7d256a42f0
push id94370
push userryanvm@gmail.com
push dateThu, 31 Aug 2017 15:52:00 +0000
treeherdermozilla-inbound@383c01a3dcb0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1328008
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1328008 - Stop collapsing TreeView nodes when clicking a value. r=Honza
devtools/client/jsonview/test/browser_jsonview_valid_json.js
devtools/client/shared/components/tree/tree-view.js
--- a/devtools/client/jsonview/test/browser_jsonview_valid_json.js
+++ b/devtools/client/jsonview/test/browser_jsonview_valid_json.js
@@ -9,25 +9,30 @@ const TEST_JSON_URL = URL_ROOT + "valid_
 
 add_task(function* () {
   info("Test valid JSON started");
 
   let tab = yield addJsonViewTab(TEST_JSON_URL);
 
   ok(tab.linkedBrowser.contentPrincipal.isNullPrincipal, "Should have null principal");
 
-  let countBefore = yield getElementCount(".jsonPanelBox .treeTable .treeRow");
-  ok(countBefore == 3, "There must be three rows");
+  is(yield countRows(), 3, "There must be three rows");
 
   let objectCellCount = yield getElementCount(
     ".jsonPanelBox .treeTable .objectCell");
-  ok(objectCellCount == 1, "There must be one object cell");
+  is(objectCellCount, 1, "There must be one object cell");
 
   let objectCellText = yield getElementText(
     ".jsonPanelBox .treeTable .objectCell");
-  ok(objectCellText == "", "The summary is hidden when object is expanded");
+  is(objectCellText, "", "The summary is hidden when object is expanded");
 
-  // Collapsed auto-expanded node.
+  // Clicking the value does not collapse it (so that it can be selected and copied).
+  yield clickJsonNode(".jsonPanelBox .treeTable .treeValueCell");
+  is(yield countRows(), 3, "There must still be three rows");
+
+  // Clicking the label collapses the auto-expanded node.
   yield clickJsonNode(".jsonPanelBox .treeTable .treeLabel");
+  is(yield countRows(), 1, "There must be one row");
+});
 
-  let countAfter = yield getElementCount(".jsonPanelBox .treeTable .treeRow");
-  ok(countAfter == 1, "There must be one row");
-});
+function countRows() {
+  return getElementCount(".jsonPanelBox .treeTable .treeRow");
+}
--- a/devtools/client/shared/components/tree/tree-view.js
+++ b/devtools/client/shared/components/tree/tree-view.js
@@ -208,17 +208,20 @@ define(function (require, exports, modul
           return;
       }
 
       event.preventDefault();
     },
 
     onClickRow: function (nodePath, event) {
       event.stopPropagation();
-      this.toggle(nodePath);
+      let cell = event.target.closest("td");
+      if (cell && cell.classList.contains("treeLabelCell")) {
+        this.toggle(nodePath);
+      }
       this.selectRow(nodePath);
     },
 
     getSelectedRow: function (rows) {
       if (!this.state.selected || rows.length === 0) {
         return null;
       }
       return rows.find(row => this.isSelected(row.props.member.path));