mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Preserve focus when switching between pane items
If the pane is currently focused, when showing a view associated with a new item, focus that view.
This commit is contained in:
committed by
probablycorey
parent
80859b0a9f
commit
52b649dca5
@@ -44,6 +44,15 @@ describe "Pane", ->
|
||||
expect(itemChangedHandler.argsForCall[0][1]).toBe editSession1
|
||||
itemChangedHandler.reset()
|
||||
|
||||
describe "if the pane's active view is focused before calling showItem", ->
|
||||
it "focuses the new active view", ->
|
||||
container.attachToDom()
|
||||
pane.focus()
|
||||
expect(pane.activeView).not.toBe view2
|
||||
expect(pane.activeView).toMatchSelector ':focus'
|
||||
pane.showItem(view2)
|
||||
expect(view2).toMatchSelector ':focus'
|
||||
|
||||
describe "when the given item isn't yet in the items list on the pane", ->
|
||||
view3 = null
|
||||
beforeEach ->
|
||||
|
||||
@@ -73,11 +73,13 @@ class Pane extends View
|
||||
|
||||
showItem: (item) ->
|
||||
return if item is @activeItem
|
||||
isFocused = @is(':has(:focus)')
|
||||
@addItem(item)
|
||||
view = @viewForItem(item)
|
||||
@itemViews.children().not(view).hide()
|
||||
@itemViews.append(view) unless view.parent().is(@itemViews)
|
||||
view.show()
|
||||
view.focus() if isFocused
|
||||
@activeItem = item
|
||||
@activeView = view
|
||||
@trigger 'pane:active-item-changed', [item]
|
||||
|
||||
Reference in New Issue
Block a user