Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix editor alt+m focus trap #685

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "azure-iot-explorer",
"version": "0.15.11",
"version": "0.15.12",
"description": "This project welcomes contributions and suggestions. Most contributions require you to agree to a\r Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\r the rights to use your contribution. For details, visit https://cla.microsoft.com.",
"main": "host/electron.js",
"build": {
Expand Down
17 changes: 17 additions & 0 deletions src/app/shared/components/monacoEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ export const MonacoEditorComponent: React.FC<MonacoEditorComponentProps> = ({
editorDidMount={(editor): void => {
editorRef.current = editor;
placeholderContentWidget(editor, placeholder || '');

editor.addCommand(
monaco.KeyMod.Alt | monaco.KeyCode.KeyM,
() => {

/* In Electron, to fully remove focus from the Monaco Editor.
we will need to shift focus to another DOM element or window.
It is due to Electron's integration with Chromium and the way focus is managed between the webview and the main process.
We will create a dummy input, move the focus to it, and then clean it up. */
const dummyInput = document.createElement("input");
dummyInput.style.position = "absolute";
dummyInput.style.opacity = "0";
document.body.appendChild(dummyInput);
dummyInput.focus();
setTimeout(() => document.body.removeChild(dummyInput), 0);
}
);
}}
value={content}
language={language || 'json'}
Expand Down
Loading