Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Remove cursor on blur #10

benbro opened this Issue · 4 comments

2 participants


When a client remove the focus from the CodeMirror instance the browser remove his cursor but other clients still see his cursor at the same position.
If several people are editing the doc at the same time you'll end up with several cursors you can't remove.

Is it possible to listen to the "blur" even on the CodeMirror editor and send {cursor: false} to other clients? think that CodeMirror fires the cursorActivity event only when



I've pushed a commit that implements your suggestion. If you want to test it, you can clone the ot.js-demo repository and do a cd node_modules && git clone there. Currently, when the user selects some text and focuses another window, the selected text will disappear from the other user's screens while the user who did the selection can still see it. Do you think that I should fix this?


I've tested the blur on a cursor (with no selection) and it works great.

I think it's important that both users will see exactly the same.
Any blur event will remove the selection not just focus of another window.
If I'm talking on the phone with someone and asking him to look at the text I selected but he doesn't see that because I clicked somewhere else it will be very confusing.

Maybe trigger the blur event in CodeMirrorAdapter only if there is no selection?


I agree with you that the goal should be that all users see the same. There's even one additional case that must be dealt with: if a user makes some edits, focuses another window (thus the focus on the CodeMirror instance is lost and the blur event fires) and then comes back to the editor window, making the cursor visible again. I think implementing this should be a matter of catching the focus event and sending the cursor information.

@timjb timjb closed this

I've implemented the re-adding of the cursor on focus in cc55f31.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.