Trying to capure cmd+s/ctrl+s does not work if you paste, triggers the file browser

Hi, we capture ctrl+s/cmd+s here gerrit/gr-editor-view.ts at master · GerritCodeReview/gerrit · GitHub

But that works intermittent with codemirror v6 (worked with v5). When we paste it doesn’t work immediately, instead triggers the file browser. Waiting a few seconds works. If you manually type on the keyboard it works immediately. Wondering if you know why or if this could be a bug in CodeMirror?

The cm code is plugins_codemirror-editor/codemirror-element.ts at master · GerritCodeReview/plugins_codemirror-editor · GitHub

I’ve tried to follow Capturing Ctrl-S doesn't work, opens browser's save dialog but it either prevents gerrit/gr-editor-view.ts at master · GerritCodeReview/gerrit · GitHub or doesn’t work exactly.

Can you set up a minimal demo that shows this? I cannot reproduce it in this setup.

Seems I found a workaround:

              // There is an issue where you paste and immediately
              // press ctrl+s/cmd+s after, it would trigger the
              // web browsers file browser rather then gr-editor-view
              // intercepting ctrl+s/cmd+s.
              if ((e.metaKey || e.ctrlKey) && e.key == 'v') {

Putting that into EditorView.domEventHandlers (keydown) seems to fix the issue.