diff --git a/src/editor/Editor.tsx b/src/editor/Editor.tsx index 7726d500..5c59b44b 100644 --- a/src/editor/Editor.tsx +++ b/src/editor/Editor.tsx @@ -429,25 +429,6 @@ const Editor: React.VFC = () => { [], ); - useEditor( - editor, - (editor) => { - // TODO: can be removed when https://github.com/microsoft/vscode/pull/146968 is merged - // HACK: The editor eats context menu key press events event when - // the monaco context menu is disabled so we have to fake it - const subscription = editor.onKeyDown((e) => { - if (e.keyCode === monaco.KeyCode.ContextMenu) { - e.target.dispatchEvent( - new MouseEvent('contextmenu', { bubbles: true }), - ); - } - }); - - return () => subscription.dispose(); - }, - [], - ); - const handleEditorDidMount = useCallback( (editor) => { editor.focus(); diff --git a/src/setupTests.ts b/src/setupTests.ts index 661024ff..59d1cf08 100644 --- a/src/setupTests.ts +++ b/src/setupTests.ts @@ -58,6 +58,10 @@ const specialCases: Record = { function addWhichToKeyboardEvent(e: KeyboardEvent) { // blueprints and testing-library both don't do this one if (e.key === 'ContextMenu') { + // HACK: work around lack of ContextMenu key support in user-events + if (e.target !== null) { + e.target.dispatchEvent(new MouseEvent('contextmenu', { bubbles: true })); + } return; }