mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Fix right click in CodeEditor that could trigger the event context menu
This commit is contained in:
@@ -49,7 +49,7 @@ export class CodeEditor extends React.Component<Props, State> {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
setupEditorCompletions = (editor: any, monaco: any) => {
|
||||
if (!monacoCompletionsInitialized) {
|
||||
@@ -91,6 +91,13 @@ export class CodeEditor extends React.Component<Props, State> {
|
||||
.catch(this.handleLoadError);
|
||||
}
|
||||
|
||||
_handleContextMenu = (event: SyntheticEvent<>) => {
|
||||
// Prevent right click to bubble up and trigger the context menu
|
||||
// of the event.
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
};
|
||||
|
||||
render() {
|
||||
const { MonacoEditor, error } = this.state;
|
||||
if (error) {
|
||||
@@ -107,6 +114,7 @@ export class CodeEditor extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
return (
|
||||
<div onContextMenu={this._handleContextMenu}>
|
||||
<PreferencesContext.Consumer>
|
||||
{({ values }) => (
|
||||
<MonacoEditor
|
||||
@@ -122,6 +130,7 @@ export class CodeEditor extends React.Component<Props, State> {
|
||||
/>
|
||||
)}
|
||||
</PreferencesContext.Consumer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user