ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

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

Open aktivdigital-frontend opened this issue 1 year ago • 1 comments

Prerequisites

Ionic Framework Version

  • [ ] v4.x
  • [ ] v5.x
  • [X] v6.x
  • [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

aktivdigital-frontend avatar Aug 17 '22 08:08 aktivdigital-frontend

@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.

sean-perkins avatar Aug 17 '22 18:08 sean-perkins

@aktivdigital-frontend Can you try the following dev build and let me know if it resolves the issue?

npm install @ionic/[email protected]

Note: You may need to install this in a local Ionic app. StackBlitz sometimes has issues installing dev builds of Ionic.

liamdebeasi avatar Oct 04 '22 16:10 liamdebeasi

Thanks for the issue. This has been resolved via https://github.com/ionic-team/ionic-framework/pull/26070, and a fix will be available in an upcoming release of Ionic Framework. Feel free to continue testing the dev build and let me know if you run into any issues.

liamdebeasi avatar Oct 10 '22 16:10 liamdebeasi

Should this problem be fixed now? When I update the above StackBlitz to 6.3.2, I get the same issue... https://stackblitz.com/edit/angular-ramjpp-squwwg?file=src%2Fapp%2Fapp.component.ts,package.json

charlesj1 avatar Oct 19 '22 00:10 charlesj1

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

aktivdigital-frontend avatar Oct 19 '22 06:10 aktivdigital-frontend