mirror of
https://github.com/atom/atom.git
synced 2026-02-06 04:34:55 -05:00
Update titles after adding/removing tabs
The duplicate title detection requires the tab be on the DOM so update the title after it is inserted and also update titles of remaining tabs after one is removed so long titles being used can go back to short titles if no other tab title duplicates exist. Closes #446
This commit is contained in:
@@ -47,9 +47,11 @@ class TabBarView extends SortableList
|
||||
tab.insertBefore(followingTab)
|
||||
else
|
||||
@append(tab)
|
||||
tab.updateTitle()
|
||||
|
||||
removeTabForItem: (item) ->
|
||||
@tabForItem(item).remove()
|
||||
tab.updateTitle() for tab in @getTabs()
|
||||
|
||||
getTabs: ->
|
||||
@children('.tab').toArray().map (elt) -> $(elt).view()
|
||||
|
||||
@@ -88,6 +88,17 @@ describe "TabBarView", ->
|
||||
expect(tabBar.getTabs().length).toBe 2
|
||||
expect(tabBar.find('.tab:contains(Item 2)')).not.toExist()
|
||||
|
||||
it "updates the titles of the remaining tabs", ->
|
||||
expect(tabBar.tabForItem(item2)).toHaveText 'Item 2'
|
||||
item2.longTitle = '2'
|
||||
item2a = new TestView('Item 2')
|
||||
item2a.longTitle = '2a'
|
||||
pane.showItem(item2a)
|
||||
expect(tabBar.tabForItem(item2)).toHaveText '2'
|
||||
expect(tabBar.tabForItem(item2a)).toHaveText '2a'
|
||||
pane.removeItem(item2a)
|
||||
expect(tabBar.tabForItem(item2)).toHaveText 'Item 2'
|
||||
|
||||
describe "when a tab is clicked", ->
|
||||
it "shows the associated item on the pane and focuses the pane", ->
|
||||
spyOn(pane, 'focus')
|
||||
|
||||
Reference in New Issue
Block a user