NavigationLink pushing extra View after List reorder

So I have a list of items, ordered by name, which I get using an @FetchRequest. Each List row has a NavigationLink, where the user can edit the name of the item. If the user edits the name of the item in such a way as to reorder the list, then taps the Back navigationBarItem, it takes them back to the List view, but then the detail view of the item they just edited is pushed again.

For example:
  • I have a list of 2 items with names 'Alpha' and 'Beta'

  • I open the detail view for 'Alpha'

  • I set the name to 'Zeta'

  • I go back to the main list view (where now the list would be ordered as 'Beta', then 'Zeta')

  • The detail view for 'Zeta' (used to be 'Alpha') is opened again

I am running Xcode 12 with iOS 14 on a physical iPhone, if anyone could help me figure out if it's a beta issue or if it's an issue in the data in my views that would be great! Happy to post code if needed, thanks!

It sounds a little like you may somehow be preserving the fact that the user has navigated into that detail page, then when the user goes back to the page before, that information somehow does not get updated, so when SwiftUI updates your UI after the fetch request has completed, it just navigates the user back to where it thinks they belong.

To explore how this could be happening, we'd probably need to see some code, but perhaps this can give you a starting point of what to explore already.
Yeah, I figured something like that might be causing the issue. Here is my code for the list view:

Code Block Swift
struct IngredientListView: View {
    @FetchRequest(entity: Ingredient.entity(), sortDescriptors: [NSSortDescriptor(key: "name", ascending: true)]) var ingredients: FetchedResults<Ingredient>
    var body: some View {
        List {
            ForEach(ingredients) { ingredient in
                NavigationLink(destination: IngredientView(ingredient: ingredient)) {
                    Text(ingredient.name)
                }
            }
        }
    }
}


The NavigationLink just goes to a detail view with a navigationBarItem to bring up a sheet where the user can edit the name of the ingredient. Thanks for the suggestions!
NavigationLink pushing extra View after List reorder
 
 
Q