mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Emit 'item-added' before setting the ::activeItem when adding first item
Fixes atom/tabs#11
This commit is contained in:
@@ -44,11 +44,16 @@ describe "Pane", ->
|
||||
pane.addItem(item4)
|
||||
expect(pane.items).toEqual [item1, item2, item4, item3]
|
||||
|
||||
it "sets the active item if it is undefined", ->
|
||||
it "sets the active item after adding the first item", ->
|
||||
pane = new Pane
|
||||
item = new Item("A")
|
||||
events = []
|
||||
pane.on 'item-added', -> events.push('item-added')
|
||||
pane.$activeItem.changes.onValue -> events.push('active-item-changed')
|
||||
|
||||
pane.addItem(item)
|
||||
expect(pane.activeItem).toBe item
|
||||
expect(events).toEqual ['item-added', 'active-item-changed']
|
||||
|
||||
describe "::activateItem(item)", ->
|
||||
pane = null
|
||||
|
||||
@@ -132,8 +132,8 @@ class Pane extends Model
|
||||
return if item in @items
|
||||
|
||||
@items.splice(index, 0, item)
|
||||
@activeItem ?= item
|
||||
@emit 'item-added', item, index
|
||||
@activeItem ?= item
|
||||
item
|
||||
|
||||
# Public: Adds the given items to the pane.
|
||||
|
||||
Reference in New Issue
Block a user