Bug 1066558 - Cant collapse a tree in web IDE, after expanding it; r=bgrins
--- a/browser/devtools/projecteditor/lib/tree.js
+++ b/browser/devtools/projecteditor/lib/tree.js
@@ -64,34 +64,40 @@ var ResourceContainer = Class({
}, false);
this.children = doc.createElementNS(HTML_NS, "ul");
this.children.classList.add("children");
this.elt.appendChild(this.children);
this.line.addEventListener("click", (evt) => {
- if (!this.selected) {
- this.select();
- this.expanded = true;
- evt.stopPropagation();
- }
+ this.select();
+ this.toggleExpansion();
+ evt.stopPropagation();
}, false);
this.expander.addEventListener("click", (evt) => {
- this.expanded = !this.expanded;
+ this.toggleExpansion();
this.select();
evt.stopPropagation();
}, true);
if (!this.resource.isRoot) {
this.expanded = false;
}
this.update();
},
+ toggleExpansion: function() {
+ if (!this.resource.isRoot) {
+ this.expanded = !this.expanded;
+ } else {
+ this.expanded = true;
+ }
+ },
+
destroy: function() {
this.elt.remove();
this.expander.remove();
this.highlighter.remove();
this.children.remove();
this.label.remove();
this.elt = this.expander = this.highlighter = this.children = this.label = null;
},
--- a/browser/devtools/projecteditor/test/browser_projecteditor_tree_selection_01.js
+++ b/browser/devtools/projecteditor/test/browser_projecteditor_tree_selection_01.js
@@ -34,20 +34,26 @@ let test = asyncTest(function*() {
function selectFileFirstLoad(projecteditor, resource) {
ok (resource && resource.path, "A valid resource has been passed in for selection " + (resource && resource.path));
projecteditor.projectTree.selectResource(resource);
let container = projecteditor.projectTree.getViewContainer(resource);
if (resource.isRoot) {
ok (container.expanded, "The root directory is expanded by default.");
+ container.line.click();
+ ok (container.expanded, "Clicking on the line does not toggles expansion.");
return;
}
if (resource.isDir) {
ok (!container.expanded, "A directory is not expanded by default.");
+ container.line.click();
+ ok (container.expanded, "Clicking on the line toggles expansion.");
+ container.line.click();
+ ok (!container.expanded, "Clicking on the line toggles expansion.");
return;
}
let [editorCreated, editorLoaded, editorActivated] = yield promise.all([
onceEditorCreated(projecteditor),
onceEditorLoad(projecteditor),
onceEditorActivated(projecteditor)
]);