Remove selection when editor looses focus

Hey together,

I am using multiple CodeMirror editors on a page. If in one editor a selection is made by the user, and then the user leaves that editor so that the editor looses focus. The selection still remains there and it remains highlighted. Is there an easy way to remove a selection when an editor looses focus?

1 Like

The default theme styles the selection background grey when the editor isn’t focused, blue when it is. You could do something similar (style ".cm-selectionBackground": {background: "transparent"}) to hide it entirely.

2 Likes

Great that works!