chore: add menu-will-close comment explaining setTimeout (#16794)

This commit is contained in:
Milan Burda 2019-02-08 22:38:03 +01:00 committed by Samuel Attard
parent 70042d2597
commit 3f52e18a38

View file

@ -71,6 +71,9 @@ ipcMainUtils.handle('ELECTRON_INSPECTOR_CONTEXT_MENU', function (event, items, i
const window = event.sender.getOwnerBrowserWindow() const window = event.sender.getOwnerBrowserWindow()
menu.once('menu-will-close', () => { 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(() => { setTimeout(() => {
event._replyInternal('ELECTRON_INSPECTOR_CONTEXT_MENU_CLOSE') event._replyInternal('ELECTRON_INSPECTOR_CONTEXT_MENU_CLOSE')
}) })