mirror of
https://github.com/atom/atom.git
synced 2026-02-14 16:45:14 -05:00
When a pane is removed, focus/activate the next pane
This commit is contained in:
committed by
probablycorey
parent
75229808de
commit
161ed69ef0
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user