Bug fix: Editor retains focus when clicked while already focused

I couldn't find a way to test this really. It's some interaction
between focusout and focus events. When the hidden input has focus and
then we call focus on the editor, the handling of the focusout event
away from input was trigerring a call to focus on the editor, which
didn't seem to trigger the handler that shifted it back to the hidden
input. Here I only focus the editor if something *outside* of the
editor was de-focused. So focusing the editor when the input is focused
is ignored, and focus is gracefully returned back to the input.
This commit is contained in:
Nathan Sobo
2012-01-24 18:14:38 -08:00
parent 90656aaffb
commit 9d911d29c5

View File

@@ -33,7 +33,9 @@ class RootView extends Template
@on 'toggle-file-finder', => @toggleFileFinder()
@on 'focusout', (e) =>
@editor.focus() unless e.target is @editor.find('input')[0]
# if anything but the editor and its input loses focus, restore focus to the editor
unless $(e.target).closest('.editor').length
@editor.focus()
createProject: (url) ->
if url