Skip to content

Commit 95887a8

Browse files
committed
fix: disable monaco's context menu in 'Load From Zulip' popup
1 parent 8b3e3c8 commit 95887a8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

client/src/App.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,20 @@ function App() {
350350
history.replaceState(undefined, undefined!, formatArgs(args))
351351
}, [editor, project, code, codeFromUrl])
352352

353+
// Disable monaco context menu outside the editor
354+
useEffect(() => {
355+
const handleContextMenu = (event: MouseEvent) => {
356+
const editorContainer = document.querySelector(".editor")
357+
if (editorContainer && !editorContainer.contains(event.target as Node)) {
358+
event.stopPropagation()
359+
}
360+
}
361+
document.addEventListener("contextmenu", handleContextMenu, true)
362+
return () => {
363+
document.removeEventListener("contextmenu", handleContextMenu, true)
364+
}
365+
}, [])
366+
353367
return <PreferencesContext.Provider value={{preferences, setPreferences}}>
354368
<div className="app monaco-editor">
355369
<nav>

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
</head>
88
<body>
9-
<div id="root" class="monaco-workbench">
9+
<div id="root">
1010
<noscript>
1111
<p>
1212
You need to enable JavaScript to use the lean web editor,

0 commit comments

Comments
 (0)