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

Fixed a bug that was causing Electron's context menu to fail #2238

Merged
merged 2 commits into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Fixed a bug that was causing Electron's context menu to fail
  • Loading branch information
tonyanziano committed Mar 3, 2021
commit 7902bf92de2afc157bb66a7aa26bedce349764a9
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [main] Bumped `electron-builder` to `22.9.1` and `electron-updater` to `4.3.5` to fix the Mac build in PR [2230](https://github.com/microsoft/BotFramework-Emulator/pull/2230)
- [client] Re-enabled the `<webview>` tag in the client so that the inspectors show again in PR [2233](https://github.com/microsoft/BotFramework-Emulator/pull/2233)
- [client] Bumped `botframework-webchat` to v4.12.0 and fixed various Web Chat-related bugs in PR [2236](https://github.com/microsoft/BotFramework-Emulator/pull/2236)
- [main] Fixed a bug that was causing Electron's native context menu to silently fail when selecting an option in PR [2238](https://github.com/microsoft/BotFramework-Emulator/pull/2238)

## v4.11.0 - 2020 - 11 - 05
- [client] Moved from master to main as the default branch. [2194](https://github.com/microsoft/BotFramework-Emulator/pull/2194)
Expand Down
12 changes: 8 additions & 4 deletions packages/app/main/src/services/contextMenuService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,24 @@
import { Menu, MenuItem, MenuItemConstructorOptions, BrowserWindow } from 'electron';
import { ContextMenuCoordinates } from '@bfemulator/app-shared';

type ContextMenuResult = {
id: string;
};

export class ContextMenuService {
private static currentMenu: Menu;

public static showMenuAndWaitForInput(
options: Partial<MenuItemConstructorOptions>[] = [],
menuCoords?: ContextMenuCoordinates
): Promise<MenuItem> {
): Promise<ContextMenuResult> {
if (ContextMenuService.currentMenu) {
ContextMenuService.currentMenu.closePopup();
}
return new Promise(resolve => {
const clickHandler = menuItem => {
return new Promise<ContextMenuResult>(resolve => {
const clickHandler = (menuItem: MenuItem) => {
ContextMenuService.currentMenu = null;
resolve(menuItem);
resolve({ id: menuItem.id });
};

const template = options.map(option => {
Expand Down