SwiftUI Multiple Wheel Picker Touch Bounds Offset and Crash iOS 15

Viewed 1267

Having an issue where my production application crashes on iOS 15. When I run it in Xcode with debug or release it doesn't crash. I have somehow managed to narrow it down to my multiple wheel picker code, they are displayed side-by-side.

Similar issue to SwiftUI problem with multiple Wheel Pickers in one list on iOS 15

For the crash I found a suggestion somewhere else to change the form to a list and add .id(UUID())

List {
   ...
}.id(UUID())

This seemed to stop the crash but if you run the code you notice the bounds of the touch area is off on the wheels meaning you cannot scroll the first wheel at all and to scroll the other ones you can touch all the way into the next wheel to move it. I've tried removing clipped and adjusting frames but the touch area seems to be offset.

Any suggestions will be helpful, I am going to also submit a feedback to apple and will edit with feedback number

See video of the offset issue Click here

Stripped down code used to reproduce the issue

import SwiftUI

struct ContentView: View {
    @State var interval:TimeInterval = 0
    @State var selectedHour = 0
    @State var selectedMin = 0
    @State var selectedSecond = 0
    
    var body: some View {
        //List {
        Form {
            Section (header: Text("Interval")) {
                HStack (spacing: 0)  {
                    Picker(selection: self.$selectedHour, label: Text("Hour")) {
                        ForEach(0..<25) { hour in
                            Text("\(hour) h")
                        }
                    }
                    .pickerStyle(WheelPickerStyle())
                    .frame(minWidth: 100, maxWidth: .infinity)
                    .clipped()
                    
                    Picker(selection: self.$selectedMin, label: Text("Min")) {
                        ForEach(0..<60) { min in
                            Text("\(min) m")
                        }
                    }
                    .pickerStyle(WheelPickerStyle())
                    .frame(minWidth: 100, maxWidth: .infinity)
                    .clipped()
                    
                    Picker(selection: self.$selectedSecond, label: Text("Sec")) {
                        ForEach(0..<60) { sec in
                            Text("\(sec) s")
                        }
                    }
                    .pickerStyle(WheelPickerStyle())
                    .frame(minWidth: 100, maxWidth: .infinity)
                    .clipped()
                }
                .mask(Rectangle())
            }
        }//.id(UUID())
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Edit: Apple Feedback #FB9648846

0 Answers
Related