I am using a SectionedFetchRequest that groups my Core Data Objects by a String Field. Each object is put inside of a NavigationLink to show the detail view, where the user can edit the Grouping Field.
When the user edits the grouping field, the detail view is immediately dismissed (or popped from the navigation stack).
I believe this is due to using a "tag" and "selection" inside of the Navigation Link. Because the object moves to a different section, a new navigation link is generated, and the old Navigation link view is removed. This causes the detail view to get popped off of the stack. Any ideas to get this behavior to stop?
Here is some code to show the situation:
struct SessionsList: View {
@SectionedFetchRequest(fetchRequest: Session.fecthRequest(NSPredicate.all), sectionIdentifier: \.sectionDate) var sectionedSessions
@State private var selection: String?
var body: some View {
NavigationView {
List {
ForEach(sectionedSessions) { section in
Section(header: Text(section.id))) {
ForEach(section) { session in
NavigationLink(destination: SessionView(session: session), tag: session.unique, selection: $selection) {
SessionRow(session: session)
}
}
}
}
}
}
}
This is in iOS15. The main problem is that the detail view gets dismisses each time they type a letter in the grouping field. So they can only edit it one letter at a time.