Open vigorouscoding opened 5 months ago
Im a bit stumped, I just found that this does not happen in Firefox on Windows but on Mac it does.
Also, I experimented with the other playgrounds and found that for example in the "Listening to Mouse Events" playground, it works in all the editors on the left (Source, HTML, CSS) but the problem does not occur in the resulting monaco editor on the lower right.
Screen recording is attached, where I demonstrate the problem using the "Auto-Reload" checkbox for my "mouse up" position after dragging.
I was unable to find out why the problem does not show in the lower right editor but I'll see if I can find more information and maybe even a workaround.
https://github.com/microsoft/monaco-editor/assets/3099108/65a166f3-b100-4f42-8b8a-0fdb8a92e6c3
Probably another case of #4378
Looks like the cause for #4378 is a quite recent. This popped up in our app and we are still on 0.38.0 (and is reproducible up until the most recent version), so I'll leave it open for now
On Windows in Firefox it's still an issue, when leaving editor selection firefox calls click
event on buttons/anchors outside of monaco.
Monaco version - 0.48,
Firefox version - 125.0.2
still an issue on monaco 0.50, firefox 128.0b5 (64-bit)
Still an issue with v0.50, firefox v127.02 (64 bit) on linux as well.
I was able to workaround this via:
document.addEventListener('mouseup', this.onMouseup, true);
document.addEventListener('click', this.onClick, true);
---
onMouseup(event: MouseEvent) {
this.lastMouseEventTarget = event.target;
}
onClick(event: MouseEvent) {
if (this.lastMouseEventTarget !== event.target) {
event.stopPropagation();
event.preventDefault();
}
}
Reproducible in vscode.dev or in VS Code Desktop?
Reproducible in the monaco editor playground?
Monaco Editor Playground Link
https://microsoft.github.io/monaco-editor/playground.html?source=v0.46.0#example-creating-the-editor-hello-world
Monaco Editor Playground Code
Reproduction Steps
Actual (Problematic) Behavior
The release of the mouse button is interpreted as a click on the element and the default click action is executed (checkbox: toggle checkbox ; link: navigates away from an editor with possibly unsaved changes).
Expected Behavior
The mouse up should be interpreted as the final step of selecting text in the editor.
Additional Context
I recorded a minimal example. It is just one Mouse Down and one Mouse Up.
https://github.com/microsoft/monaco-editor/assets/3099108/27bb235a-7b94-4b3d-b008-59bb53c2794b