I have a segmented picker to filter the list rows inside a ForEach but the NavigationLinks stop working when filtering, they have the tap animation but never change view. I am using CoreData for the deck. When I tap the rows in Standard they work normally, then I tap Wild and the NavigationLinks still work but then when I go back to standard this is what happens:
This is the code I have:
ForEach(decks.filter{$0.format == formats[selectedFormat]}, id: \.self) { deck in
HStack {
ZStack {
DeckRow(deck: deck)
NavigationLink(destination: DeckView()) {
EmptyView()
}
}
}
}
The provided code is not testable, but by reading assume the reason of issue is in equal navigation links, try the following (that will result in updating links on filtering)
ZStack {
DeckRow(deck: deck)
NavigationLink(destination: DeckView()) {
EmptyView()
}.id(deck) // << here !!
}
or, as it would be expected, make that DeckView
dependent on deck
, like DeckView(model: deck)
, which also make each navigation link unique and refreshable on filter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With