Skip to content

Commit 50b0114

Browse files
committed
fix: restore context menu icons on macOS 27
1 parent 8c39b95 commit 50b0114

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎EdgeMark/UI/Components/NSContextMenuModifier.swift‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ private struct NSContextMenuOverlay: NSViewRepresentable {
9191

9292
override func rightMouseDown(with event: NSEvent) {
9393
if let menu = menuBuilder?() {
94+
menu.prepareItemImagesForContextPresentation()
9495
NSMenu.popUpContextMenu(menu, with: event, for: self)
9596
MenuDispatch.shared.clear()
9697
}
@@ -291,6 +292,18 @@ private struct RowClickOverlay: NSViewRepresentable {
291292
// MARK: - NSMenu Builder Helpers
292293

293294
extension NSMenu {
295+
/// macOS 27 hides menu-item images by default. Context menus in EdgeMark use
296+
/// icons as stable action cues, so opt every imaged item and submenu back in.
297+
func prepareItemImagesForContextPresentation() {
298+
guard #available(macOS 27.0, *) else { return }
299+
for item in items {
300+
if item.image != nil {
301+
item.preferredImageVisibility = .visible
302+
}
303+
item.submenu?.prepareItemImagesForContextPresentation()
304+
}
305+
}
306+
294307
/// Pop up this menu (built with addActionItem) at a point in a view without an NSEvent.
295308
/// Blocks until dismissed, then clears MenuDispatch closures.
296309
func popUpAtPoint(_ point: NSPoint, in view: NSView) {

0 commit comments

Comments
 (0)