mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Merge pull request #14183 from atom/ns-fix-focus-when-toggling-docks
Properly restore focus to center when hiding dock via toggle
This commit is contained in:
@@ -25,6 +25,12 @@ describe('Dock', () => {
|
||||
|
||||
dock.hide()
|
||||
expect(document.activeElement).toBe(atom.workspace.getCenter().getActivePane().getElement())
|
||||
|
||||
dock.activate()
|
||||
expect(document.activeElement).toBe(dock.getActivePane().getElement())
|
||||
|
||||
dock.toggle()
|
||||
expect(document.activeElement).toBe(atom.workspace.getCenter().getActivePane().getElement())
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -112,7 +112,6 @@ module.exports = class Dock {
|
||||
// was previously focused.
|
||||
hide () {
|
||||
this.setState({visible: false})
|
||||
this.didHide()
|
||||
}
|
||||
|
||||
// Extended: Toggle the dock's visiblity without changing the {Workspace}'s
|
||||
@@ -133,12 +132,14 @@ module.exports = class Dock {
|
||||
setState (newState) {
|
||||
const prevState = this.state
|
||||
const nextState = Object.assign({}, prevState, newState)
|
||||
let didHide = false
|
||||
|
||||
// Update the `shouldAnimate` state. This needs to be written to the DOM before updating the
|
||||
// class that changes the animated property. Normally we'd have to defer the class change a
|
||||
// frame to ensure the property is animated (or not) appropriately, however we luck out in this
|
||||
// case because the drag start always happens before the item is dragged into the toggle button.
|
||||
if (nextState.visible !== prevState.visible) {
|
||||
didHide = !nextState.visible
|
||||
// Never animate toggling visiblity...
|
||||
nextState.shouldAnimate = false
|
||||
} else if (!nextState.visible && nextState.draggingItem && !prevState.draggingItem) {
|
||||
@@ -148,6 +149,7 @@ module.exports = class Dock {
|
||||
|
||||
this.state = nextState
|
||||
this.render(this.state)
|
||||
if (didHide) this.didHide()
|
||||
}
|
||||
|
||||
render (state) {
|
||||
|
||||
Reference in New Issue
Block a user