SwiftUI / Core Data / TabView / Master Detailed View / NavigationLink
see sample project
The code is using NavigationLink(destination,tag,selection) to programmatically navigate from a master view to detailed view. Removing the tag/selection removes the problem but doesn't remove my need to trigger the navigation link programmatically.
Master view uses a @FetchRequest which includes multiple NSSortDescriptors which values are changed/saved in detailed view.
When the 'pinned' value is changed and saved (pinned is also a NSSortDescriptor for the master view's list) the app navigates involuntary from the detailed view to another instance of the detailed view before navigating back to the master view or other times navigates back to the master view and then back to the detailed view.
The only way to prevent this behavior is to remove the 'pinned' NSSortDescriptors from the @FetchRequest
I also get the following warning: [TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window)....
Replicate:
In the included sample app (link above) add 6 new 'tasks' and they are saved into Core Data.
Then navigate to any of the detailed task view and change the pinned value and select save. This should provoke the involuntary navigation to a new instance of the detailed view before ending up involuntary on the master view or other times navigates back to the master view and then back to the detailed view.
MacOS 10.15.6 / Xcode Version 11.6 / iOS 13.6
see sample project
The code is using NavigationLink(destination,tag,selection) to programmatically navigate from a master view to detailed view. Removing the tag/selection removes the problem but doesn't remove my need to trigger the navigation link programmatically.
Master view uses a @FetchRequest which includes multiple NSSortDescriptors which values are changed/saved in detailed view.
When the 'pinned' value is changed and saved (pinned is also a NSSortDescriptor for the master view's list) the app navigates involuntary from the detailed view to another instance of the detailed view before navigating back to the master view or other times navigates back to the master view and then back to the detailed view.
The only way to prevent this behavior is to remove the 'pinned' NSSortDescriptors from the @FetchRequest
I also get the following warning: [TableView] Warning once only: UITableView was told to layout its visible cells and other contents without being in the view hierarchy (the table view or one of its superviews has not been added to a window)....
Replicate:
In the included sample app (link above) add 6 new 'tasks' and they are saved into Core Data.
Then navigate to any of the detailed task view and change the pinned value and select save. This should provoke the involuntary navigation to a new instance of the detailed view before ending up involuntary on the master view or other times navigates back to the master view and then back to the detailed view.
MacOS 10.15.6 / Xcode Version 11.6 / iOS 13.6