CloudKit causes SwiftUI Menu to be dismissed

After updating to iOS 17 and Xcode 15 I noticed that menus on my app get automatically dismissed while CloudKit is syncing data right after opening the app. I know it's CloudKit because this issue doesn't happen when I launch the app in Airplane Mode.

It looks like CloudKit causes something to change (even when there are no data changes since the last usage), which causes the UI to refresh. This refresh causes the menus to be dismissed.

This is frustrating because users have to tap a button two or three times before being able to interact with the menu showed by the button. I'm attaching a screen recording that shows the issue:

https://youtube.com/shorts/Wl9gP2HLktE

  1. I open the app and tap the "+" icon, which shows the menu.
  2. The menu is quickly dismissed.
  3. I tap the "+" icon again, and the menu is shown for a millisecond, and is dismissed again.
  4. I tap the "+" button once again. This time the menu is shown and stays there because CloudKit has finished its initial sync process.

Note that this didn't happened on iOS 16 / Xcode 14, so something must have changed to cause this issue. Is there something I need to update on my code to fix this issue, or is it a bug in the OS or frameworks that will be fixed in a future update?

I’m having the exact same issue with Menu in SwiftUI dismissing itself. I’m using SwiftData and Core Data but I’m not using CloudKit though. I don’t remember this happening back on iOS 16 either.

I noticed if I switch between tabs and toggle the menu, it dismisses itself. I’m running a task in the view and ended up moving it to my view model and calling it in the initializer, now I’m not seeing the Menu being dismissed.

Hi @marcosatanaka

Have you managed to solve this issue? I am having the same problem but with TapKit. I can see the Tip showing, but it was dismissed shortly after because of the CloudKit syncing.

CloudKit causes SwiftUI Menu to be dismissed
 
 
Q