SectionedFetchRequest Causes Detail View to get dismissed when object changes section.

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.

I found a work around. In the detail view, I don't edit the grouping field directly and instead use a @State var to edit the grouping field. Then I hide the back button and use a custom back button, that will set the grouping field right before I dismiss the view. That way the view stays in place until they hit the back button.

Is there a better way to do this?

SectionedFetchRequest Causes Detail View to get dismissed when object changes section.
 
 
Q