Skip to content

bug: ion-datetime does not scroll to value #28548

Description

@aparajita

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

According to the ion-datetime docs:

If its value is updated programmatically after a datetime has already been created, the datetime will automatically jump to the new date.

Here's what I'm seeing:

  • Create an ion-datetime in calendar presentation mode.
  • Scroll to a different month.
  • Click to set the value to a date in that month.
  • Programmatically set the value to a date in a different month.
  • The value changes, but the calendar does not scroll to the target month.

Expected Behavior

The calendar should scroll to the month of the value when it changes.

Steps to Reproduce

  1. Open the demo at https://stackblitz.com/edit/8d9oqr?file=src%2Fcomponents%2FExample.vue.
  2. Scroll to any month other than November 2023.
  3. Click on a date in that month. The value changes accordingly.
  4. Click "Reset". The value is changed to 2023-11-17T00:00:00, but the calendar does move.

Code Reproduction URL

https://stackblitz.com/edit/8d9oqr?file=src%2Fcomponents%2FExample.vue

Ionic Info

Ionic:

Ionic CLI : 7.1.5

Utility:

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

System:

NodeJS : v20.5.0
npm : 9.8.0
OS : macOS Unknown

Additional Information

In Brave v1.60.118, the calendar does not visually move at all when clicking Reset. In Safari 17.0 (18616.1.27.111.22, 18616), the calendar scrolls a little bit and then snaps back to the same month.

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