From db438be40b87dd6f3b1e2727e939ba6561a8fce3 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Tue, 22 Nov 2022 13:54:01 -0600 Subject: [PATCH] editor: finish remove hack TODO The upstream fix was merged, so the workaround is no longer needed. --- src/editor/Editor.tsx | 19 ------------------- src/setupTests.ts | 4 ++++ 2 files changed, 4 insertions(+), 19 deletions(-) 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; }