Skip to content

Commit

Permalink
Fixed a bug that was causing Electron's context menu to fail (#2238)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyanziano authored Mar 4, 2021
1 parent a4685d6 commit 16c9b03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ 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 where we were expecting the incorrect shape from Electron's updated `dialog.showOpenDialog()` API in PR [2237](https://github.com/microsoft/BotFramework-Emulator/pull/2237)
- [main] Fixed a bug where we were expecting the incorrect shape from Electron's updated `dialog.showOpenDialog()` API in PR [2237](https://github.com/microsoft/BotFramework-Emulator/pull/2237)
- [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

0 comments on commit 16c9b03

Please sign in to comment.