iPadOS 17.1 SwiftUI DatePicker with onTapGesture

We have met a problem with iPadOS 17.1.

We have a normal date picker 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 date picker, the calendar view is popup and lets us choose the date. But when we updated to 17.1, the calendar is not shown as a normal click, only a long press gesture will trigger it.

Can someone help to take a look at it?

Here is the sameple 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") } } }

Facing similar issue, app is crashing when we select time from datepicker on iOS 17.1.

Also facing the same issue. It seems the .onTapGesture is forcing the pickers and buttons to require long press. If you find a solution, please post...

same problem here...

Same issue, even on iPhones

Same issue. Have you filed a Feedback Report? Here's mine: FB13455112

Face the same issue here, is there anything new please?

Hi there! I may resolved this issue.

The approach is open date picker by the programmatically. But It is may lack of accuracy

Use the following link to programmatically open the Date Picker How to trigger SwiftUI datepicker programmatically This question uses a button to display the Date Picker, but we need to open the Date Picker using onTapGesture.

DatePicker("", selection: $date, displayedComponents: .date)
    .accessibilityIdentifier(pickerId)
    .onTapGesture {
        triggerDatePickerPopover()
    }

Besides, just implementing the previous solution did not work. (For some reason, triggerDatePickerPopover() did not get the Date Picker properly.) In my case, I opened the Accessibility Inspector in Xcode and clicked on the target Date Picker, and after that, I was able to get it to work.

Hope everyone's problems will be solved soon! Thank you.

(I used a translator, so my English may be strange!)

Hi everyone! temporary workaround by Roy Rodney add .onTapGesture modifier with count, for example DatePicker( "Foo", selection: $date, displayedComponents: .date ) .onTapGesture(count: 99, perform: { // overrides tap gesture to fix ios 17.1 bug })

see link below for more detail https://stackoverflow.com/questions/77373659/swiftui-datepicker-issue-ios-17-1

Not working

Same problem here

iPadOS 17.1 SwiftUI DatePicker with onTapGesture
 
 
Q