vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Extensions using webview prevent window focus when using preventDefault & stopPropagation

Open AThilenius opened this issue 3 years ago • 1 comments

Continuation of #124318

To reiterate, extensions using a webview that call e.preventDefault(); and e.stopPropagation(); in onmousedown within the webview itself, prevent vscode from focusing the window altogether. This is problematic for me because the editor in question is a single canvas (all custom drawing using WebGL) that still needs to listen to keyboard events.

Steps to Reproduce:

  1. Clone https://github.com/AThilenius/vscode-issue-124318
  2. npm i, code . and hit F5
  3. Open exampleFiles/example.cscratch and a new tab next to it.
  4. Notice that you can focus the custom editor with the first button, but not the second

Note: my repo is just a clone of https://github.com/microsoft/vscode-extension-samples/tree/main/custom-editor-sample, and apart from the .gitignore the only changes made are these: https://github.com/AThilenius/vscode-issue-124318/commit/9087bb5be337cd65edb00e1b2fae53f24fba5bfb

  • VS Code Version: 1.69.0 92d25e35d9bf1a6b16f7d0758f25d48ace11e5b9 x64
  • OS Version: Win 11, WSL2 (largely irrelevant though, this is a client-side/Electron issue).

Happy to take a workaround if you know of one! I need the context menu to not show up on right-click though.

AThilenius avatar Jul 10 '22 05:07 AThilenius

Well, answered my own question by asking about the workaround 🤦‍♂️ Just use oncontextmenu to prevent the context menu and let the onmousedown event bubble.

I'm going to leave this open in case you want to consider it a bug still. I could see it going either way. But please feel free to close if you think it's intended behavior.

AThilenius avatar Jul 10 '22 06:07 AThilenius

We closed this issue because we don't plan to address it in the foreseeable future. If you disagree and feel that this issue is crucial: we are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding, and happy coding!

vscodenpa avatar Dec 05 '22 19:12 vscodenpa