Focus the active center pane when hiding a dock

This commit is contained in:
Nathan Sobo
2017-04-05 20:58:05 -06:00
parent 9ecbc85be5
commit 73f04fdaed
3 changed files with 21 additions and 1 deletions

View File

@@ -16,6 +16,18 @@ describe('Dock', () => {
})
})
describe('when a dock is hidden', () => {
it('transfers focus back to the active center pane', () => {
jasmine.attachToDOM(atom.workspace.getElement())
const dock = atom.workspace.getLeftDock()
dock.activate()
expect(document.activeElement).toBe(dock.getActivePane().getElement())
dock.hide()
expect(document.activeElement).toBe(atom.workspace.getCenter().getActivePane().getElement())
})
})
describe('when a pane in a dock is activated', () => {
it('opens the dock', async () => {
const item = {

View File

@@ -33,6 +33,7 @@ module.exports = class Dock {
this.deserializerManager = params.deserializerManager
this.notificationManager = params.notificationManager
this.viewRegistry = params.viewRegistry
this.didHide = params.didHide
this.paneContainer = new PaneContainer({
location: this.location,
@@ -103,6 +104,7 @@ module.exports = class Dock {
hide () {
this.setState({open: false})
this.didHide()
}
toggle () {

View File

@@ -36,6 +36,7 @@ module.exports = class Workspace extends Model {
this.updateDocumentEdited = this.updateDocumentEdited.bind(this)
this.didDestroyPaneItem = this.didDestroyPaneItem.bind(this)
this.didChangeActivePaneItem = this.didChangeActivePaneItem.bind(this)
this.didHideDock = this.didHideDock.bind(this)
this.packageManager = params.packageManager
this.config = params.config
@@ -112,12 +113,17 @@ module.exports = class Workspace extends Model {
applicationDelegate: this.applicationDelegate,
deserializerManager: this.deserializerManager,
notificationManager: this.notificationManager,
viewRegistry: this.viewRegistry
viewRegistry: this.viewRegistry,
didHide: this.didHideDock
})
dock.onDidDestroyPaneItem(this.didDestroyPaneItem)
return dock
}
didHideDock () {
this.getCenter().getActivePane().activate()
}
reset (packageManager) {
this.packageManager = packageManager
this.emitter.dispose()