From 8e77c05c0664a8d075f2854d21dfddf3c937f117 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Sat, 28 Jan 2012 22:36:47 -0700 Subject: [PATCH] Fix bug: Don't scroll to top on click after scrolling down. The editor has a tabindex of -1 so it can receive focus. This makes it behave like a focusable element such as a textarea. But in reality, when the editor receives focus, it just focuses the hidden input that it watches for textInput events. So when you click, focus is stolen away from the hidden input and goes to the editor. But then the editor sends focus back to the hidden input. Because the input was at the top of the screen, WebKit would scroll up to bring it on screen when focused. So now I just bring the hidden input on screen (by positioning it even with scrollTop) before focusing it. That prevents the WebKit from scrolling. --- src/atom/editor.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/atom/editor.coffee b/src/atom/editor.coffee index d7856ae3e..4454d5d2d 100644 --- a/src/atom/editor.coffee +++ b/src/atom/editor.coffee @@ -64,6 +64,7 @@ class Editor extends Template handleEvents: -> @on 'focus', => + @hiddenInput.css(top: @scrollTop()) @hiddenInput.focus() false