question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: Setting ion-datetime value does not update selected day

See original GitHub issue

Prerequisites

Ionic Framework Version

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

Current Behavior

When setting the value of an ion-datetime in a setTimeout, the display date updates, but after opening the datetime, the selected day does not display.

Expected Behavior

After setting the value of a ion-datetime, the selected day should also update.

Steps to Reproduce

  1. Have an ion-datetime (example uses ion-datetime-button)
  2. Update the value after a few seconds
  3. Open the date picker
  4. Observe: The new value does not show as the selected day
  5. Expected: The new value would display as the highlighted/selected day

Code Reproduction URL

https://stackblitz.com/edit/angular-ramjpp?file=src%2Fapp%2Fexample.component.html,src%2Fapp%2Fexample.component.ts

Ionic Info

N/A

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
aktivdigital-frontendcommented, Oct 19, 2022

@liamdebeasi Highlight is OK, thanks, but the picker show the current month, not the set month. This issue is only partially finished.

1reaction
sean-perkinscommented, Aug 17, 2022

@aktivdigital-frontend thanks for reporting this issue. I am seeing the same behavior as well.

The datetime has internal logic that requires the date be active & that we should highlight the day: https://github.com/ionic-team/ionic-framework/blob/436a8ce50847d26f8fb63ce64ea85be6f5c0bc8e/core/src/components/datetime/datetime.tsx#L1927

highlightActiveParts is unfortunately never set when the value is dynamically changed, so the day will never show as selected unless the user manually taps the day again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ion-datetime dynamic value change doesn't work for certain ...
The way I do this is by listening to the ionChange event, detecting the clicked day, calculating the 7 days that belong to...
Read more >
ion-datetime - Ionic Framework
Datetimes present a picker interface to select dates and times. Ionic's API Datetime input component easily displays a preferred format, and manages values....
Read more >
Date picker popup in Ionic 6 | Damir's Corner
To make the ion-datetime component appear in a popup, place it inside the ion-popover component. To display the selected date on the page,...
Read more >
What's new in Ionic 6.2 release | ion-datetime-button - YouTube
Hello Friends, Welcome Back to @CodingTechnyks. In this video, we are going to use new ion - datetime component & ion - datetime...
Read more >
How to use the Ionic 6 Datetime component - YouTube
In this video we are taking a closer look at the Ionic 6 datetime component and implement a stylish modal that works for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found