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.
This commit is contained in:
Nathan Sobo 2012-01-28 22:36:47 -07:00
parent a77dd28e47
commit 8e77c05c06

View File

@ -64,6 +64,7 @@ class Editor extends Template
handleEvents: ->
@on 'focus', =>
@hiddenInput.css(top: @scrollTop())
@hiddenInput.focus()
false