@DTS Engineer Thank you for your response Albert,
Is it timing the issue?
I don't think it is a timing issue because even if I don't trigger a navigation, basically just removing the action code for the "Edit" button, nothing happens, the system doesn't dismiss the context menu when an option is selected automatically. If that would happen I could try to get away with a short delay before presenting. (not ideal though)
you should avoid calling UIKit's present() manually from a SwiftUI button action
Thanks for the suggestion, unfortunately my whole project still relies on UINavigationControllers and UIHostingControllers to manage navigation and presentation, but I want to revisit migrating to full SwiftUI approach since its support has improved greatly with the introduction of NavigationStack.
I tried the following just to see what happens:
Since the context menu doesn't disappear when an option is tapped and no action is triggered, I tried updating a string property annotated with @State and if it has a valid value I simply insert a Text into the view stack, this also didn't make the menu disappear.
Trying a .sheet modifier as you suggested works fine, the action menu disappears and then the sheet is presented.
However, I feel like my use case is also a valid use case though, many iOS projects are still in the process of migrating to SwiftUI, and I know from colleagues and friends that many are still relying on UINavigationController/UIHostingControllers for pushing and presenting views.
Do you think this is something that can be investigated or fixed on your end? If so, I can also send a report through the feedback assistant. If not, then I would just not use toolbar item group until I can migrate to SwiftUI presentation.
Thanks!