We have met a problem with iPadOS 17.1.
We have a normal DatePicker to choose the date, but in the meantime, we added an onTapGesture to it and did something.
With the previous version 17.0, when we click the DatePicker, the calendar view is poping up and let's us choose the date. But when we updated to 17.1, the calendar is not shown with a normal click, only a long press gesture will trigger it.
Here is the sample code:
@main
struct TestApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
struct ContentView: View {
var body: some View {
DatePicker("test", selection: .constant(Date()), displayedComponents: .date)
.onTapGesture {
print("on tap")
}
}
}
The expectation is the calendar should be shown when the picker is tapped.
I think that
DatePickerandonTapGestureare fighting to be first, which gives an undefined behaviour that could be different at any time. It is probably better to use.simultaneousGesture(_:)in this situation.For example: