`disabled` does not wok in List selection

disabled does not wok in List selection

struct ListDisableTest: View {
  let disableIDs: [Int] = [1, 3]
  @State var selection: Set<Int> = []

  var body: some View {
    List(1..<20, id: \.self, selection: $selection) { i in
      Text("\(i)")
        .tag(i)
        .disabled(disableIDs.contains(i))
    }
    .environment(\.editMode, .constant(.active))
  }
}

disabled works, but not the way you expect.

I tested a variation of your code, replacing Text("(i)") by a button.

Then, the buttons (1, 3 dimmed) are disabled (see screenshot). But the selection of cell is not disabled.

That shows that the button for multiple selection is not concerned by disabled (it is not the item in List).

struct ListDisableTest: View {
  let disableIDs: [Int] = [1, 3]
  @State var selection: Set<Int> = []

  var body: some View {
    List(1..<20, id: \.self, selection: $selection) { i in
        Button(action: { print("Hi, I'm \(i)")}, label:  { Text("\(i)") })
        .tag(i)
        .disabled(disableIDs.contains(i))
    }
    .environment(\.editMode, .constant(.active))
  }
}

Note: however action is never fired…

`disabled` does not wok in List selection
 
 
Q