Skip to content

bug: (ios) ion-datetime not selecting time with ion-datetime-button #29926

Closed as duplicate of#29672
@sergiomilici

Description

@sergiomilici

Prerequisites

Ionic Framework Version

v8.x

Current Behavior

On iOS (16.7.10) using Capacitor 6.1, the component ion-datetime is emitting ionChange with the value of event.detail.value in undefined. It only works if, after stopping the wheels in the desire time, you touch that number (and the keyboard shows up). Otherwise, visually you see the time selected, but the emitted event doesn't have the correct time.

It works okay on Mac Chrome, Safari, and Android.

This is really strange. The same thing happens using ionic official documentation when playing with the widgets in Safari mobile.

Example code:

<ion-datetime-button datetime="datetime"></ion-datetime-button>

<ion-modal [keepContentsMounted]="true">
  <ng-template>
    <ion-datetime id="datetime"        
                            [showDefaultButtons]="true"
                           (ionChange)="ionDateChanged($event)">
</ion-datetime>
  </ng-template>
</ion-modal>
 ionDateChanged(event) {
    console.log('ionDateChanged: ', event);
  }
RPReplay_Final1728423253.mp4

Expected Behavior

After the wheel of hour or minute stops, the event ionChange emits a value that has the correct time.

Steps to Reproduce

This could be tested using the stackblitz from ionic official documentation. This is the code to run in Safari or capacitor

Code Reproduction URL

https://stackblitz.com/run?file=src%2Fapp%2Fapp.component.ts

Ionic Info

Ionic:

Ionic CLI : 7.2.0 (/Users/chicho/.nvm/versions/node/v22.6.0/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 8.3.2
@angular-devkit/build-angular : 18.2.4
@angular-devkit/schematics : 18.2.4
@angular/cli : 18.2.4
@ionic/angular-toolkit : 12.1.1

Capacitor:

Capacitor CLI : 6.1.2
@capacitor/android : 6.1.2
@capacitor/core : 6.1.2
@capacitor/ios : 6.1.2

Cordova:

Cordova CLI : not installed
Cordova Platforms : not available
Cordova Plugins : not available

Utility:

cordova-res : not installed globally
native-run : 2.0.1

System:

NodeJS : v22.6.0 (/Users/chicho/.nvm/versions/node/v22.6.0/bin/node)
npm : 10.8.2
OS : macOS Unknown
Xcode : Xcode 15.4 Build version 15F31d

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions