Skip to content

Commit

Permalink
chore: add menu-will-close comment explaining setTimeout (#16794)
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak authored and MarshallOfSound committed Feb 8, 2019
1 parent 70042d2 commit 3f52e18
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/browser/chrome-devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ ipcMainUtils.handle('ELECTRON_INSPECTOR_CONTEXT_MENU', function (event, items, i
const window = event.sender.getOwnerBrowserWindow()

menu.once('menu-will-close', () => {
// menu-will-close is emitted before the click handler, but needs to be sent after.
// otherwise, DevToolsAPI.contextMenuCleared() would be called before
// DevToolsAPI.contextMenuItemSelected(id) and the menu will not work properly.
setTimeout(() => {
event._replyInternal('ELECTRON_INSPECTOR_CONTEXT_MENU_CLOSE')
})
Expand Down

0 comments on commit 3f52e18

Please sign in to comment.