When a pane is removed, focus/activate the next pane

This commit is contained in:
Kevin Sawicki & Nathan Sobo
2013-02-21 17:42:51 -07:00
committed by probablycorey
parent 75229808de
commit 161ed69ef0
4 changed files with 77 additions and 5 deletions

View File

@@ -19,9 +19,19 @@ class PaneContainer extends View
focusNextPane: ->
panes = @getPanes()
currentIndex = panes.indexOf(@getFocusedPane())
if panes.length > 1
currentIndex = panes.indexOf(@getFocusedPane())
nextIndex = (currentIndex + 1) % panes.length
panes[nextIndex].focus()
true
else
false
makeNextPaneActive: ->
panes = @getPanes()
currentIndex = panes.indexOf(@getActivePane())
nextIndex = (currentIndex + 1) % panes.length
panes[nextIndex].focus()
panes[nextIndex].makeActive()
getRoot: ->
@children().first().view()

View File

@@ -171,7 +171,13 @@ class Pane extends View
# find parent elements before removing from dom
container = @getContainer()
parentAxis = @parent('.row, .column')
if @is(':has(:focus)')
rootView?.focus() unless container.focusNextPane()
else if @isActive()
container.makeNextPaneActive()
super
if parentAxis.children().length == 1
sibling = parentAxis.children().detach()
parentAxis.replaceWith(sibling)