mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
When the last pane is destroyed, null out the root and active pane
This commit is contained in:
@@ -66,6 +66,11 @@ describe "PaneContainerModel", ->
|
||||
container = new PaneContainerModel(root: pane)
|
||||
container.on 'surrendered-focus', surrenderedFocusHandler = jasmine.createSpy("surrenderedFocusHandler")
|
||||
|
||||
it "assigns null to the root and the activePane", ->
|
||||
pane.destroy()
|
||||
expect(container.root).toBe null
|
||||
expect(container.activePane).toBe null
|
||||
|
||||
describe "if the pane is focused", ->
|
||||
it "emits a 'surrendered-focus' event", ->
|
||||
pane.focus()
|
||||
|
||||
@@ -14,6 +14,8 @@ class PaneContainerModel extends Model
|
||||
focusContext: null
|
||||
activePane: null
|
||||
|
||||
previousRoot: null
|
||||
|
||||
@behavior 'activePaneItem', ->
|
||||
@$activePane.flatMapLatest (activePane) -> activePane?.$activeItem
|
||||
|
||||
@@ -22,11 +24,7 @@ class PaneContainerModel extends Model
|
||||
|
||||
@focusContext ?= new FocusContext
|
||||
|
||||
@subscribe @$root, (root) =>
|
||||
if root?
|
||||
root.parent = this
|
||||
root.container = this
|
||||
@activePane ?= root if root instanceof PaneModel
|
||||
@subscribe @$root, @onRootChanged
|
||||
|
||||
deserializeParams: (params) ->
|
||||
@focusContext ?= params.focusContext ? new FocusContext
|
||||
@@ -76,3 +74,17 @@ class PaneContainerModel extends Model
|
||||
@activePane = panes[nextIndex]
|
||||
else
|
||||
@activePane = null
|
||||
|
||||
onRootChanged: (root) =>
|
||||
@unsubscribe(@previousRoot) if @previousRoot?
|
||||
@previousRoot = root
|
||||
return unless root?
|
||||
|
||||
root.parent = this
|
||||
root.container = this
|
||||
|
||||
if root instanceof PaneModel
|
||||
@activePane ?= root
|
||||
@subscribe root, 'destroyed', =>
|
||||
@activePane = null
|
||||
@root = null
|
||||
|
||||
Reference in New Issue
Block a user