When using a NavigationLink inside a ForEach in a NavigationStack, if the ordering of the list changes whilst a detail view is presented, the detail view changes its content to the element in the ForEach that is at the same index, rather than retaining the same view.
This doesn't happen with Vanilla SwiftUI or when appending to the path in a Reducer from e.g. a button tap.
Checklist
[X] I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
[X] If possible, I've reproduced the issue using the main branch of this package.
The views in a NavigationStack path shouldn't change with list ordering or underlying ForEach NavigationLinks.
The following project shows this doesn't happen for Vanilla SwiftUI.
ReorderTest.zip
Actual behavior
If list ordering of NavigationLinks changes in the ForEach of the root view in the stack then detail views change their content.
Here I have edited SyncUps to sort sync ups based on title when tapping 'Start Meeting' rather than starting the meeting (to simply show the unexpected behaviour).
In the video attached, when I edit Sync Up "Test 1" (3rd element in the list) to "Test 3" and trigger the sort of the list, the item in the detail view changes to "Test 2" (3rd element in the updated list).
Description
When using a NavigationLink inside a ForEach in a NavigationStack, if the ordering of the list changes whilst a detail view is presented, the detail view changes its content to the element in the ForEach that is at the same index, rather than retaining the same view. This doesn't happen with Vanilla SwiftUI or when appending to the path in a Reducer from e.g. a button tap.
Checklist
main
branch of this package.Expected behavior
The views in a NavigationStack path shouldn't change with list ordering or underlying ForEach NavigationLinks.
The following project shows this doesn't happen for Vanilla SwiftUI. ReorderTest.zip
Actual behavior
If list ordering of
NavigationLink
s changes in the ForEach of the root view in the stack then detail views change their content. Here I have edited SyncUps to sort sync ups based ontitle
when tapping 'Start Meeting' rather than starting the meeting (to simply show the unexpected behaviour). In the video attached, when I edit Sync Up "Test 1" (3rd element in the list) to "Test 3" and trigger the sort of the list, the item in the detail view changes to "Test 2" (3rd element in the updated list).https://github.com/pointfreeco/swift-composable-architecture/assets/156822019/4029aba9-d442-4e70-b7ee-a83de85baa19
Steps to reproduce
In the sync up example app, change
in
AppFeature.swift
toThe Composable Architecture version information
1.11.1
Destination operating system
iOS 17
Xcode version information
Xcode 15.4
Swift Compiler version information