diff --git a/spec/app/pane-spec.coffee b/spec/app/pane-spec.coffee index b67b41449..a55650699 100644 --- a/spec/app/pane-spec.coffee +++ b/spec/app/pane-spec.coffee @@ -257,6 +257,13 @@ describe "Pane", -> expect(pane2.getItems()).toEqual [view3, editSession1] expect(editSession1.destroyed).toBeFalsy() + describe "when the item is a jQuery object", -> + it "preserves data by detaching instead of removing", -> + view1.data('preservative', 1234) + pane.moveItemToPane(view1, pane2, 1) + pane2.showItemAtIndex(1) + expect(pane2.activeView.data('preservative')).toBe 1234 + describe "core:close", -> it "destroys the active item and does not bubble the event", -> containerCloseHandler = jasmine.createSpy("containerCloseHandler") diff --git a/src/app/pane.coffee b/src/app/pane.coffee index fe96299c8..166fd7e90 100644 --- a/src/app/pane.coffee +++ b/src/app/pane.coffee @@ -214,7 +214,9 @@ class Pane extends View @trigger 'pane:item-moved', [item, newIndex] moveItemToPane: (item, pane, index) -> + @isMovingItem = true @removeItem(item) + @isMovingItem = false pane.addItem(item, index) itemForUri: (uri) -> @@ -235,8 +237,12 @@ class Pane extends View delete @viewsByClassName[viewClass.name] if @items.length > 0 - viewToRemove?.remove() + if @isMovingItem and item is viewToRemove + viewToRemove?.detach() + else + viewToRemove?.remove() else + viewToRemove?.detach() if @isMovingItem and item is viewToRemove @remove() viewForItem: (item) ->