Skip to content

Use async menu popup - #998

Merged
niik merged 3 commits into
masterfrom
async-menu-popup
Mar 6, 2017
Merged

niik merged 3 commits into
masterfrom
async-menu-popup

Conversation

@kevinsawicki

@kevinsawicki kevinsawicki commented Mar 2, 2017 •

Copy link
Copy Markdown
Contributor

This is a new Electron option that came out today that I would love to know if it works well in Desktop.

It allows menu.popup to return immediately so the render loop doesn't stall on macOS. There is also a new menu.closePopup as well in case you ever need to close an open menu.

See electron/electron#8702 for more details.

This fails to compile locally for me:

ERROR in ./app/src/main-process/main.ts
(161,24): error TS2345: Argument of type '{ async: boolean; }' is not assignable to parameter of type 'number | undefined'.
  Type '{ async: boolean; }' is not assignable to type 'number'.

Any typescript tips for working around it?

Comment thread app/src/main-process/main.ts Outdated

This comment was marked as spam.

@shiftkey

shiftkey commented Mar 2, 2017

Copy link
Copy Markdown
Member

@kevinsawicki if you cast menu to any you can circumvent the type checker:

const anyMenu: any = menu
anyMenu.popup(window, { async: true })

To properly fix it it looks like we need to update this signature - I see this is what 1.6.1 looks like https://electron.atom.io/docs/api/menu/#menupopupbrowserwindow-x-y-positioningitem

@kevinsawicki

Copy link
Copy Markdown
Contributor Author

@shiftkey thanks for that 👍 Pushed an update.

@shiftkey

shiftkey commented Mar 6, 2017

Copy link
Copy Markdown
Member

@kevinsawicki just pulled this down - doesn't seem to make a huge difference on our side, but that's probably because we're not letting the user do anything noticeable on the render loop at that point to highlight the issue.

I've opened #1003 to track the type signature work needed, but I'll let someone else from @desktop/core chime on when we want to merge this...

@niik

niik commented Mar 6, 2017

Copy link
Copy Markdown
Member

Let's try it out and get some mileage for the electron team

@niik
niik merged commit 34d0fcf into master Mar 6, 2017
@niik
niik deleted the async-menu-popup branch March 6, 2017 11:21
niik added a commit that referenced this pull request Mar 8, 2017
This hack shouldn't be necessary as of #998. Let's try it and see if that theory holds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants