Yes, I have the same problem in some lists in my app. Rows stay highlighted after navigating back.
I have created a really easy solution to remove the highlight color in these situations. I use NotificationCenter to notify when the NavigationLink is tapped and use some UIKit-magic to deselect the cells. Works like a charm. All you need to do is add this block of code. Note that if your list has multiple sections, you have to modify the code.
.onReceive(NotificationCenter.default.publisher(for: UITableView.selectionDidChangeNotification)) { notification in
if let tableView = notification.object as? UITableView {
let numberOfRows = tableView.numberOfRows(inSection: 0)
guard numberOfRows 0 else { return }
for i in 0...rows - 1 {
tableView.deselectRow(at: IndexPath(row: i, section: 0), animated: true)
}
}
}
Post
Replies
Boosts
Views
Activity
Tested on just released 14.5 Beta 4. All the issues still remain.
And remember. This is not a simulator only issue. If you have released SwiftUI iPad-apps that use sidebar, this is a problem for you.
New 14.5 Beta 5 was just released. Issue still remains. Still no response from Apple to my feedback. I just send an email to app support, let's see if I can get a response in that way.
In thew meanwhile, please test my issue and send also feedback to Apple. They have introduced an undocumented change to navigationsystem in SwiftUI and it's really bad for exsisting apps.