From 27f203cfc2d514d807fff2a10eb924061bdf3417 Mon Sep 17 00:00:00 2001 From: Manu Jain Date: Wed, 8 Oct 2014 15:49:48 -0700 Subject: [PATCH] Bug 1066558 - Cant collapse a tree in web IDE, after expanding it; r=bgrins --- browser/devtools/projecteditor/lib/tree.js | 18 ++++++++++++------ .../browser_projecteditor_tree_selection_01.js | 6 ++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/browser/devtools/projecteditor/lib/tree.js b/browser/devtools/projecteditor/lib/tree.js index 3a142c3d33f..3cdc3bf6c73 100644 --- a/browser/devtools/projecteditor/lib/tree.js +++ b/browser/devtools/projecteditor/lib/tree.js @@ -69,14 +69,12 @@ var ResourceContainer = Class({ 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); @@ -87,6 +85,14 @@ var ResourceContainer = Class({ this.update(); }, + toggleExpansion: function() { + if (!this.resource.isRoot) { + this.expanded = !this.expanded; + } else { + this.expanded = true; + } + }, + destroy: function() { this.elt.remove(); this.expander.remove(); diff --git a/browser/devtools/projecteditor/test/browser_projecteditor_tree_selection_01.js b/browser/devtools/projecteditor/test/browser_projecteditor_tree_selection_01.js index d2458a3a468..334351f6d1b 100644 --- a/browser/devtools/projecteditor/test/browser_projecteditor_tree_selection_01.js +++ b/browser/devtools/projecteditor/test/browser_projecteditor_tree_selection_01.js @@ -39,10 +39,16 @@ function selectFileFirstLoad(projecteditor, 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; }