From 9d911d29c52edd5e79db205e845055a3016afbe2 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 24 Jan 2012 18:14:38 -0800 Subject: [PATCH] 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. --- src/atom/root-view.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/atom/root-view.coffee b/src/atom/root-view.coffee index 360dbae5c..cdf337226 100644 --- a/src/atom/root-view.coffee +++ b/src/atom/root-view.coffee @@ -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