0

After updating to Xcode 14 and iOS 16 on my devices the lists in my app seems broken in a number of ways. The problem I'm describing here seems to occur when using a List in a NavigationView that contains two views. When the List elements has a custom background using .listRowBackground and EditMode is activated, the selected row sometimes get a blue outline. It only occurs when I'm running on iPad (regular mode). It does not follow the selection of rows but seem to appear randomly over the list. Anyone else encountered this and have come up with a fix? Seems like a total bug to me. I will report it to Apple if I'm not getting explanation here.

enter image description here

The code to reproduce the error:

struct ContentView: View {

    let myStrings = ["string1", "string2", "string3"]
    @State var selection = Set<String>()

    var body: some View {
        NavigationView {
            List(selection: $selection) {
                ForEach(myStrings, id: \.self) { myString in
                    Text(myString)
                        .listRowBackground(Color(UIColor.secondarySystemGroupedBackground))
                }
            }
            .listStyle(.insetGrouped)
            .toolbar {
                EditButton()
            }
            EmptyView()
        }
    }
}

I'm running Xcode 14.2 and iPadOS 16.2.

EDIT: Seems like it only appears on iPad when having an external keyboard connected.

Albin
  • 105
  • 9
  • 1
    Same question [here](https://stackoverflow.com/questions/73892237/swiftui-navigationsplitview-on-ipad-remove-accent-from-selected-item-in-sidebar). No answer yet. – HunterLion Dec 21 '22 at 10:01
  • Have you tried babysitting what SwiftUI may consider highlight-worth for keyboard navigation via @FocusState? – Alex Fringes Dec 23 '22 at 12:03

2 Answers2

0

If you custom-color either the listRowBackground or the listRowSeparator, you'll get this result. It's SwiftUI showing the user what item was selected.

Remove the listRowBackground modifier and you'll see the list item itself colored in the tintColor, rather the the list item being bordered in the tintColor.

Andrew
  • 21
  • 3
  • Yes removing listRowBackround makes the checkbox and title look more reasonable. The point is however that I want a custom background. It worked in previous versions of SwiftUI, it works on simulator and on iPhone so it is weird that it would not work on iPad. My temporary solution at the moment is however to avoid the custom background until Apple comes up with a solution. – Albin Jan 11 '23 at 13:01
0

This solution work for me... Please try

Just set "AccentColor" in Assets as clear color

Darshit Shah
  • 2,366
  • 26
  • 33