Bug 1328008 - Stop collapsing TreeView nodes when clicking a value. r=Honza

This commit is contained in:
Oriol Brufau 2017-08-30 07:27:00 -04:00
parent 8dfeaddc82
commit a1f7ac5069
2 changed files with 17 additions and 9 deletions

View File

@ -14,20 +14,25 @@ add_task(function* () {
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");
let countAfter = yield getElementCount(".jsonPanelBox .treeTable .treeRow");
ok(countAfter == 1, "There must be one row");
is(yield countRows(), 1, "There must be one row");
});
function countRows() {
return getElementCount(".jsonPanelBox .treeTable .treeRow");
}

View File

@ -213,7 +213,10 @@ define(function (require, exports, module) {
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);
},