From a8d94f37f769744490d7fd808f97c94ee1b02c0c Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Thu, 25 Oct 2012 14:03:26 -0700 Subject: [PATCH] core:close events close the Tree View (but not the entire window) --- src/extensions/tree-view/spec/tree-view-spec.coffee | 13 +++++++++++++ src/extensions/tree-view/src/tree-view.coffee | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/extensions/tree-view/spec/tree-view-spec.coffee b/src/extensions/tree-view/spec/tree-view-spec.coffee index d15495ece..de9617065 100644 --- a/src/extensions/tree-view/spec/tree-view-spec.coffee +++ b/src/extensions/tree-view/spec/tree-view-spec.coffee @@ -194,6 +194,19 @@ describe "TreeView", -> expect(treeView).not.toMatchSelector(':focus') expect(rootView.getActiveEditor().isFocused).toBeTruthy() + describe "when core:close is triggered on the tree view", -> + it "detaches the TreeView, focuses the RootView and does not bubble the core:close event", -> + treeView.attach() + treeView.focus() + rootViewCloseHandler = jasmine.createSpy('rootViewCloseHandler') + rootView.on 'core:close', rootViewCloseHandler + spyOn(rootView, 'focus') + + treeView.trigger('core:close') + expect(rootView.focus).toHaveBeenCalled() + expect(rootViewCloseHandler).not.toHaveBeenCalled() + expect(treeView.hasParent()).toBeFalsy() + describe "when a directory's disclosure arrow is clicked", -> it "expands / collapses the associated directory", -> subdir = treeView.root.find('.entries > li:contains(dir1/)').view() diff --git a/src/extensions/tree-view/src/tree-view.coffee b/src/extensions/tree-view/src/tree-view.coffee index 363f66726..eb8c55720 100644 --- a/src/extensions/tree-view/src/tree-view.coffee +++ b/src/extensions/tree-view/src/tree-view.coffee @@ -50,7 +50,7 @@ class TreeView extends ScrollView @on 'click', '.entry', (e) => @entryClicked(e) @command 'core:move-up', => @moveUp() @command 'core:move-down', => @moveDown() - @command 'core:close', => @detatch() + @command 'core:close', => @detach(); false @command 'tree-view:expand-directory', => @expandDirectory() @command 'tree-view:collapse-directory', => @collapseDirectory() @command 'tree-view:open-selected-entry', => @openSelectedEntry(true)