Fix double navigation on workout log row tap
A row tap pushed twice: a value-based navigationDestination(for: String.self) collided with the row's NavigationLink(value:), surfacing a duplicate split list over the hidden exercise detail. Rows now use a destination-based NavigationLink, leaving navigationDestination(item:) as the view's only destination.
This commit is contained in:
@@ -26,9 +26,11 @@ struct WorkoutLogListView: View {
|
||||
@State private var logToDelete: WorkoutLogDocument?
|
||||
@State private var addedLog: AddedLogRoute?
|
||||
|
||||
/// Wrapper so the programmatic push after adding an exercise uses a distinct
|
||||
/// `navigationDestination(item:)` and doesn't collide with the value-based
|
||||
/// row links registered for `String`.
|
||||
/// Drives the programmatic push into a freshly-added exercise via
|
||||
/// `navigationDestination(item:)`. Rows navigate with plain destination-based
|
||||
/// `NavigationLink`s, so this is the only `navigationDestination` in the view —
|
||||
/// stacking a second one (e.g. a value-based `for: String.self`) made a single
|
||||
/// row tap push twice.
|
||||
private struct AddedLogRoute: Identifiable, Hashable { let id: String }
|
||||
|
||||
init(workout: Workout) {
|
||||
@@ -65,7 +67,9 @@ struct WorkoutLogListView: View {
|
||||
Form {
|
||||
Section(header: Text(label)) {
|
||||
ForEach(sortedLogs) { log in
|
||||
NavigationLink(value: log.id) {
|
||||
NavigationLink {
|
||||
ExerciseView(workout: workout, logID: log.id)
|
||||
} label: {
|
||||
CheckboxListItem(
|
||||
status: workoutStatus(log).checkboxStatus,
|
||||
title: log.exerciseName,
|
||||
@@ -96,9 +100,6 @@ struct WorkoutLogListView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationDestination(for: String.self) { logID in
|
||||
ExerciseView(workout: workout, logID: logID)
|
||||
}
|
||||
.navigationDestination(item: $addedLog) { route in
|
||||
// Seed with our working doc so the brand-new log is available before
|
||||
// the cache catches up.
|
||||
|
||||
Reference in New Issue
Block a user