Description
Normally, pop to a List will also deselect the cell along with the pop transition, and this behavior depends on the value of NavigationLink in SwiftUI.
However, NavigationLink.init(state:label:fileID:filePath:line:column:) will increment the id each time, making the value unique.
|
@Dependency(\.stackElementID) var stackElementID |
|
self.init(value: state.map { StackState.Component(id: stackElementID(), element: $0) }) { |
With this implementation, the cell selection will not be retained during the push and pop, so the cell will be deselected instantly when pop (not during the transition).
Checklist
Expected behavior
The value of NavigationLink remains the same when the state is the same.

Actual behavior
The value of NavigationLink changes each time.

Reproducing project
https://github.com/pointfreeco/swift-composable-architecture/blob/main/Examples/CaseStudies/SwiftUICaseStudies/04-NavigationStack.swift
Description
Normally, pop to a
Listwill also deselect the cell along with the pop transition, and this behavior depends on thevalueofNavigationLinkin SwiftUI.However,
NavigationLink.init(state:label:fileID:filePath:line:column:)will increment theideach time, making thevalueunique.swift-composable-architecture/Sources/ComposableArchitecture/Observation/NavigationStack+Observation.swift
Lines 249 to 250 in 7c2ed5d
With this implementation, the cell selection will not be retained during the push and pop, so the cell will be deselected instantly when pop (not during the transition).
Checklist
mainbranch of this package.Expected behavior
The
valueofNavigationLinkremains the same when thestateis the same.Actual behavior
The
valueofNavigationLinkchanges each time.Reproducing project
https://github.com/pointfreeco/swift-composable-architecture/blob/main/Examples/CaseStudies/SwiftUICaseStudies/04-NavigationStack.swift