From 797e6a7913047f2dca39f298adcd6abc2a8e0cdc Mon Sep 17 00:00:00 2001 From: Amirreza Gholami Date: Tue, 14 Jul 2026 23:27:13 +0330 Subject: [PATCH] fix(macos-tray): use native performClick for context menu to fix wrong popup position --- src/native/macos/tray.swift | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/native/macos/tray.swift b/src/native/macos/tray.swift index 5a7be9a..e64eb9f 100644 --- a/src/native/macos/tray.swift +++ b/src/native/macos/tray.swift @@ -51,13 +51,11 @@ private class MenuDelegate: NSObject, NSMenuDelegate { guard let ctx = contexts[trayPtr] else { return } if event.type == .rightMouseUp || event.modifierFlags.contains(.control) { - if let menu = ctx.contextMenu { + if let menu = ctx.statusItem.menu != nil ? ctx.statusItem.menu : ctx.contextMenu { ctx.menuOpenedCallback?(trayPtr) - let menuLocation = NSPoint( - x: sender.frame.minX, - y: sender.frame.minY - 5 - ) - menu.popUp(positioning: nil, at: menuLocation, in: sender) + ctx.statusItem.menu = menu + sender.performClick(nil) + ctx.statusItem.menu = nil } } else if event.type == .leftMouseUp { let callbackPtr = trayPtr.advanced(by: 24)