With this test app:
import SwiftUI
enum Route
{
case first
case second
}
@main struct NavigatorApp : App
{
@State private var path: [Route] = [.first]
var body: some Scene
{
WindowGroup
{
NavigationStack(path: $path)
{
StartView()
}
}
}
}
struct StartView : View
{
var body: some View
{
Form
{
Section
{
NavigationLink(value: Route.first)
{
Text("Go First")
}
}
}
.navigationTitle("Start")
.navigationDestination(for: Route.self)
{ route in
switch route
{
case .first:
FirstView()
case .second:
SecondView()
}
}
}
}
struct FirstView : View
{
var body: some View
{
Form
{
Section
{
NavigationLink(value: Route.second)
{
Text("Go Second")
}
}
}
.navigationTitle("First")
}
}
struct SecondView : View
{
@State private var hasOption: Bool = false
var body: some View
{
Form
{
Section
{
Toggle("Some Option", isOn: $hasOption)
}
}
.navigationTitle("Second")
}
}
Why is the deselection animation of the "Go First" cell different/lacking/wrong when popping back to StartView
the first time (when having a non-empty NavigationStack
path)?
Is there anything I could do to fix this?
Here's a GIF of the unexpected 'animation' ("Go First" cell background jumps from grey to white):
Here a GIF of the normal animation ("Go First" background animates from grey to white):