Skip to content

Commit 1e00334

Browse files
authored
refactor: tray click events (#1766)
- avoid random `TypeError: event.preventDefault is not a function` (closes #1762) - double-click opens webui (closes #17649)
1 parent 71756f5 commit 1e00334

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/tray.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,20 @@ module.exports = function (ctx) {
262262
ctx.launchWebUI('/files', { focus: false })
263263
})
264264

265+
const popupMenu = (event) => {
266+
// https://github.com/ipfs-shipyard/ipfs-desktop/issues/1762 ¯\_(ツ)_/¯
267+
if (event && typeof event.preventDefault === 'function') event.preventDefault()
268+
269+
tray.popUpContextMenu()
270+
}
271+
265272
if (!IS_MAC) {
266273
// Show the context menu on left click on other
267274
// platforms than macOS.
268-
tray.on('click', event => {
269-
event.preventDefault()
270-
tray.popUpContextMenu()
271-
})
275+
tray.on('click', popupMenu)
272276
}
277+
tray.on('right-click', popupMenu)
278+
tray.on('double-click', () => ctx.launchWebUI('/'))
273279

274280
const setupMenu = () => {
275281
menu = buildMenu(ctx)

0 commit comments

Comments
 (0)