codemirror copies text even if blurred

Hi @marijn,

Its difficult to explain so I recorded it. pgadmin-copy-cm-issue.mov - Google Drive
Basically, when I select something in codemirror, then go to some outside element and hit copy - then it still copies codemirror text. When I do the same thing but before going to outside element, I focus on a input element like textarea, then go to some outside element and hit copy - then it works fine.

Issue raised in pgAdmin - Ctrl+C to copy does not work in data grid · Issue #7920 · pgadmin-org/pgadmin4 · GitHub

Edited: The grid below handles keydown and on ctrl+c copies the code to clipboard. I tried to preventDefault/stopPropagation from grid but it didn’t work.

Appreciate your efforts.

I don’t know what the page your are on in that screencast is doing with focus and DOM selection, but if I try to reproduce this with a simple focusable non-input element (a paragraph with tabindex=0), I cannot copy the previously-selected text from CodeMirror after I focus that element.

Hi @marijn,

Thank you for looking into it. I will try to create a minimal reproducible stackblitz if there is any issue with CM.