diff --git a/spec/dock-spec.js b/spec/dock-spec.js index afcc5527f..d18f97136 100644 --- a/spec/dock-spec.js +++ b/spec/dock-spec.js @@ -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 = { diff --git a/src/dock.js b/src/dock.js index 14f2dcef2..132150fca 100644 --- a/src/dock.js +++ b/src/dock.js @@ -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 () { diff --git a/src/workspace.js b/src/workspace.js index a90eb3e04..f3a2b9623 100644 --- a/src/workspace.js +++ b/src/workspace.js @@ -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()