Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
filip131311 committed Oct 10, 2024
1 parent 415e606 commit 2dff65d
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/vscode-extension/src/webview/components/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,16 @@ function Preview({
}
}

function onContextMenu(e: MouseEvent<HTMLDivElement>) {
e.preventDefault();
}

useEffect(() => {
// this is a fix that disables context menu on windows https://github.com/microsoft/vscode/issues/139824
// there is an active backlog item that changes the bahaviour of context menu, so it might not be necessery
// in the future https://github.com/microsoft/vscode/issues/225411
function onContextMenu(e) {
e.stopImmediatePropagation();
}

window.addEventListener("contextmenu", onContextMenu, true);

function onBlurChange() {
if (!document.hasFocus()) {
setIsPanning(false);
Expand All @@ -426,7 +431,10 @@ function Preview({
}
}
addEventListener("blur", onBlurChange, true);
return () => removeEventListener("blur", onBlurChange, true);
return () => {
window.removeEventListener("contextmenu", onContextMenu);
removeEventListener("blur", onBlurChange, true);
};
}, []);

useEffect(() => {
Expand Down Expand Up @@ -505,7 +513,6 @@ function Preview({
onMouseUp,
onMouseEnter,
onMouseLeave,
onContextMenu,
};

const resizableProps = useResizableProps({
Expand Down

0 comments on commit 2dff65d

Please sign in to comment.