UICommand is disabled on UIMenu inside NSMenuToolbarItem.itemMenu on Catalyst

Before beta 4 this worked as expected. After updating to beta 4, all my UICommands inside UIMenu on NSMenuToolbarItem.itemMenu are now disabled, and I can't figure out how to enable them.

Here's my itemForItemIdentifier method:

Code Block
func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? {
let item = NSMenuToolbarItem(itemIdentifier: itemIdentifier)
item.itemMenu = UIMenu(title: "", options: .displayInline, children: [UICommand(title: "Test", action: #selector(onTestTap))])
item.image = UIImage(systemName: "ellipsis.circle")
return item
}


Am I doing something wrong or is this a bug on macOS Big Sur beta 4?


I submitted feedback for this. I saw the same regression between beta3 and 4. In my case I was actually assigning a UIMenu of UIActions, so there was no chance of an un-found selector causing the disabled state.
It now works as expected on beta 5.
I've got this bug as well in XCode 12.4. Submenus are disabled. Any thoughts?

Edit: Using UIAction instead for UICommand fixed it!
When using a UICommand in a menu, the an object that responds to the selector must be somewhere in the responder chain, starting from the first responder, or if the first responder is nil, a view belonging to the frontmost UIViewController.

Which object is responding to the onTestTap selector?

Hi, I have a similar problem as UIMenu doesn't show UICommand from the NavigationBar item with selector defined in UIViewController which has canBecomeFirstResponder. Would you have any suggestions in that case? Thank you!

UICommand is disabled on UIMenu inside NSMenuToolbarItem.itemMenu on Catalyst
 
 
Q