editor: finish remove hack TODO

The upstream fix was merged, so the workaround is no longer needed.
This commit is contained in:
David Lechner
2022-11-22 15:56:56 -06:00
committed by David Lechner
parent 764083e6be
commit db438be40b
2 changed files with 4 additions and 19 deletions
-19
View File
@@ -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<EditorDidMount>(
(editor) => {
editor.focus();
+4
View File
@@ -58,6 +58,10 @@ const specialCases: Record<string, string> = {
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;
}