Focus the root view when canceling the move dialog.

This is temporary, because we really want to focus the tree view, but less annoying for now than losing focus entirely.
This commit is contained in:
Nathan Sobo
2012-04-27 18:08:30 -06:00
parent 18ccee32b8
commit abcf71af8b
3 changed files with 19 additions and 2 deletions

View File

@@ -338,11 +338,20 @@ describe "TreeView", ->
dirView.expand()
expect(dirView.entries.children().length).toBe 0
describe "when 'tree-view:cancel' is triggered on the move dialog", ->
it "removes the dialog and focuses root view", ->
rootView.attachToDom()
moveDialog.trigger 'tree-view:cancel'
expect(moveDialog.parent()).not.toExist()
expect(rootView.activeEditor().isFocused).toBeTruthy()
describe "when the move dialog's editor loses focus", ->
it "removes the dialog", ->
it "removes the dialog and focuses root view", ->
rootView.attachToDom()
rootView.focus()
expect(moveDialog.parent()).not.toExist()
expect(rootView.activeEditor().isFocused).toBeTruthy()
# expect(rootView).toMatchSelector(':focus')
describe "file system events", ->
temporaryFilePath = null

View File

@@ -6,3 +6,4 @@ window.keymap.bindKeys '.tree-view'
window.keymap.bindKeys '.move-dialog .mini.editor'
'enter': 'tree-view:confirm'
'escape': 'tree-view:cancel'

View File

@@ -163,8 +163,9 @@ class MoveDialog extends View
initialize: (@project, @path) ->
@editor.focus()
@editor.on 'focusout', => @remove()
@on 'tree-view:confirm', => @confirm()
@on 'tree-view:cancel', => @cancel()
@editor.on 'focusout', => @remove()
relativePath = @project.relativize(@path)
@editor.setText(relativePath)
@@ -175,3 +176,9 @@ class MoveDialog extends View
confirm: ->
fs.move(@path, @project.resolve(@editor.getText()))
@remove()
$('#root-view').focus()
cancel: ->
@remove()
$('#root-view').focus()