CodeMirror nodeviews using drawSelection don't hide their cursor when they lose focus

Our PM editor allows users to display code blocks using CodeMirror nodeviews. We’ve found that if the drawSelection extension is enabled in those CM editors, they don’t hide their cursor when they lose focus. Here’s what we see:

multiple-cursors

If I remove drawSelection, then everything works as expected. Does anyone know how to deal with this? Perhaps there’s some configuration I’m not aware of.

Are you using a recent version of @codemirror/view? Any CSS you’re overriding or messing with? There is a CSS rule that only makes the cursor only visible when there’s a focused CodeMirror editor above it, which should generally avoid this kind of thing.

I just upgraded to 6.17, and I still see the issue. (BTW, let me know if I should move this discussion over to CodeMirror discuss…I wasn’t initially sure where it should go).

The above CSS looks relevant - .cm-cursor and .ͼ1.cm-focused in particular - so I guess the strange bit is that the cm-editor still has cm-focused when I’ve moved out of it (see that there are two cursors in the screen cap). Is there some way I can be subverting the code which is supposed to remove the cm-focused class?

That should be removed on the blur event, so I’m not really sure how it ends up still there when the editor has lost focus. Is there anything special about the way you are moving focus?

I did a careful reimplementation of this nodeview, and it works properly now. I’m not entirely sure where I went wrong the first time, but I’ve certainly learned a lot about PM since I wrote it. Thanks for your help on this.