Skip to content

bug: Setting ion-datetime value programatically does not update the grid #26391

Closed
@charlesj1

Description

@charlesj1

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x
  • Nightly

Current Behavior

If you change the value of an ion-datetime programatically, and then open the ion-datetime, the calendar grid still displays the month/year of the old date.

E.g. if you programatically change the date from today to May 5, 2022, and then open the ion-datetime, the calendar grid will show today's month instead of May 2022 (if you do then navigate to May 2022, you will see that May 5 is correctly selected, but it should have opened there in the first place)

Expected Behavior

Upon opening the ion-datetime, I would expect the calendar grid to initially display the month/year of the selected date.

Steps to Reproduce

  1. Start with an ion-datetime, which defaults to today's date
  2. After 4 seconds, programatically update the date to May 5, 2022
  3. Open the date picker
    The date picker shows the current month, instead of showing May 2022
    (if you navigate back to May 2022, you will see that May 5 is highlighted as expected, but the date picker should have opened in that month to start with)

Code Reproduction URL

https://stackblitz.com/edit/angular-ramjpp-zz9vub?file=package.json

Ionic Info

Stackblitz

Additional Information

Prior to 6.3.2, the selected date was not updated either. This was reported in #25776, and I have used that as a template for this issue. Although the selected date does now get updated, the calendar grid does not open to the correct month, hence this new issue.

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