mirror of
https://github.com/electron/electron.git
synced 2026-01-09 23:48:01 -05:00
fix: close context menu before popup (#17474)
This commit is contained in:
@@ -142,6 +142,10 @@ void NotifyIcon::PopUpContextMenu(const gfx::Point& pos,
|
||||
if (!SetForegroundWindow(window_))
|
||||
return;
|
||||
|
||||
// Cancel current menu if there is one.
|
||||
if (menu_runner_ && menu_runner_->IsRunning())
|
||||
menu_runner_->Cancel();
|
||||
|
||||
// Show menu at mouse's position by default.
|
||||
gfx::Rect rect(pos, gfx::Size());
|
||||
if (pos.IsOrigin())
|
||||
|
||||
@@ -24,6 +24,23 @@ describe('tray module', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('tray.popUpContextMenu', () => {
|
||||
before(function () {
|
||||
if (process.platform !== 'win32') {
|
||||
this.skip()
|
||||
}
|
||||
})
|
||||
|
||||
it('can be called when menu is showing', (done) => {
|
||||
tray.setContextMenu(Menu.buildFromTemplate([{ label: 'Test' }]))
|
||||
setTimeout(() => {
|
||||
tray.popUpContextMenu()
|
||||
done()
|
||||
})
|
||||
tray.popUpContextMenu()
|
||||
})
|
||||
})
|
||||
|
||||
describe('tray.setImage', () => {
|
||||
it('accepts empty image', () => {
|
||||
tray.setImage(nativeImage.createEmpty())
|
||||
|
||||
Reference in New Issue
Block a user