Only move legit items to the top of the stack

Fixes #11002 cc @natalieogle
This commit is contained in:
Ben Ogle
2016-02-29 11:32:28 -08:00
parent db507a36cb
commit 920d348014
2 changed files with 5 additions and 0 deletions

View File

@@ -337,6 +337,10 @@ describe "Pane", ->
expect(pane.itemStack).toEqual [item2]
expect(pane.getActiveItem()).toBe item2
pane.destroyItem(item2)
expect(pane.itemStack).toEqual []
expect(pane.getActiveItem()).toBeUndefined()
it "invokes ::onWillDestroyItem() observers before destroying the item", ->
events = []
pane.onWillDestroyItem (event) ->

View File

@@ -307,6 +307,7 @@ class Pane extends Model
# Add item (or move item) to the end of the itemStack
addItemToStack: (newItem) ->
return unless newItem?
index = @itemStack.indexOf(newItem)
@itemStack.splice(index, 1) unless index is -1
@itemStack.push(newItem)