-
-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad focus behavior when using contenteditable on Chrome [+ Partial Fix] #3979
Comments
…or CM. This temporarily disables our support for screenreaders in the definitions area, but stomps a massively-annoying bug that caused the editor to scroll wildly onfocus(). Will re-enable this once codemirror/codemirror5#3979 is fixed
I think I've hit something like this before, and had to force inputStyle to "textArea" on mobile browsers: GerritCodeReview/gerrit@44679ef. |
Right, thus the title. |
This problem can be resolved by saving the scroller element's |
Does attached patch help? |
Works like a charm! Thanks! (Not sure what your policy is on having users close issues, so I'll leave this open for now.) |
Closing your own issues if the problem has been resolved is definitely okay! |
To reproduce:
Note: this also happens if a scrolled CM receives focus by tabbing - the display jumps up.
EXPECTED: cursor appears on the line that was clicked, and the editor does not scroll
ACTUAL: cursor sometimes appears on the line that was clicked, and the editor scrolls to put that line at the bottom of the viewport. If the line that was clicked cannot be placed at the very bottom, the editor scrolls to the very top, and the cursor appears on line 1.
This is on OSX 10.11.4, Chrome 50.
It appears that CodeMirror's input element (contentEditable or default) calls its own
focus()
method twice when receiving focus from a blurred state. I inserted some console logs before and after the focus call, printing out theBoundingClientRect
of theDisplay.mover
element. Following steps 1-4 will print out this rect four times, allowing me to see how the mover changes position.With the default input mode, the
BoundingClientRect
is the same all four times.In contentEditable mode, the first call to
focus()
switches thetop
to be the be the vertical offset of the parent CodeMirror element! If I move the editor itself so it's 200px below the top of the page, I'll see themover
element jump to 200px after the first call tofocus()
.This suggests that the focus call on https://github.com/codemirror/CodeMirror/blob/master/lib/codemirror.js#L1740 is causing the entire div to scroll to the top.
The text was updated successfully, but these errors were encountered: