Focus the active pane of docks when they are activated

This commit is contained in:
Nathan Sobo
2017-04-05 15:35:31 -06:00
committed by Max Brunsfeld
parent 334290aaa7
commit 88422ee4c9
2 changed files with 22 additions and 3 deletions

View File

@@ -3,13 +3,27 @@
import {it, fit, ffit, fffit, beforeEach, afterEach} from './async-spec-helpers'
describe('Dock', () => {
describe('when a dock is activated', () => {
it('opens the dock and activates its active pane', () => {
jasmine.attachToDOM(atom.views.getView(atom.workspace))
const dock = atom.workspace.getLeftDock()
expect(dock.isOpen()).toBe(false)
expect(document.activeElement).toBe(atom.views.getView(atom.workspace.getCenter().getActivePane()))
dock.activate()
expect(dock.isOpen()).toBe(true)
expect(document.activeElement).toBe(atom.views.getView(dock.getActivePane()))
})
})
describe('when a pane in a dock is activated', () => {
it('opens the dock', () => {
it('opens the dock', async () => {
const item = {
element: document.createElement('div'),
getDefaultLocation() { return 'left' }
}
atom.workspace.open(item, {activatePane: false})
await atom.workspace.open(item, {activatePane: false})
expect(atom.workspace.getLeftDock().isOpen()).toBe(false)
atom.workspace.getLeftDock().getPanes()[0].activate()

View File

@@ -49,7 +49,7 @@ module.exports = class Dock {
}
this.subscriptions = new CompositeDisposable(
this.paneContainer.onDidActivatePane(() => this.activate()),
this.paneContainer.onDidActivatePane(() => this.open()),
this.paneContainer.observePanes(pane => {
pane.onDidRemoveItem(this.handleDidRemovePaneItem.bind(this))
})
@@ -93,6 +93,11 @@ module.exports = class Dock {
}
activate () {
this.open()
this.getActivePane().activate()
}
open () {
this.setState({open: true})
}