Remove pane when its last item is removed

This commit is contained in:
Nathan Sobo
2013-02-21 11:12:36 -07:00
committed by probablycorey
parent 7d147dd2ce
commit 11a702a2a6
2 changed files with 5 additions and 0 deletions

View File

@@ -69,6 +69,10 @@ describe "Pane", ->
expect(pane.getItems()).toEqual [editSession1, view2]
expect(pane.currentItem).toBe editSession1
it "removes the pane when its last item is removed", ->
pane.removeItem(item) for item in pane.getItems()
expect(pane.hasParent()).toBeFalsy()
describe "when the item is a view", ->
it "removes the item from the 'item-views' div", ->
expect(view1.parent()).toMatchSelector pane.itemViews

View File

@@ -70,6 +70,7 @@ class Pane extends View
_.remove(@items, item)
item.destroy?()
@cleanupItemView(item)
@remove() unless @items.length
itemForPath: (path) ->
_.detect @items, (item) -> item.getPath?() is path