8000 fix: close context menu before popup (backport: 5-0-x) by trop[bot] · Pull Request #17509 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: close context menu before popup (backport: 5-0-x) #17509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions atom/browser/ui/win/notify_icon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
17 changes: 17 additions & 0 deletions spec/api-tray-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,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())
Expand Down
0