Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: datetime header shows 0 days selected with no value even if multiple="false" #26116

Closed
4 of 7 tasks
olaisen81 opened this issue Oct 13, 2022 · 7 comments · Fixed by #26120 or #26131
Closed
4 of 7 tasks

bug: datetime header shows 0 days selected with no value even if multiple="false" #26116

olaisen81 opened this issue Oct 13, 2022 · 7 comments · Fixed by #26120 or #26131
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@olaisen81
Copy link

olaisen81 commented Oct 13, 2022

Prerequisites

Ionic Framework Version

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

Current Behavior

DateTime showing 0 Days when initialized with formcontrol and string empty value, with Ionic version 6.2.9 all works fine.
Version 6.3.0 introduce some buggy behavior for DateTime, fixed partially with 6.3.1

Expected Behavior

DateTime show current date if initialized with string empty value in FormControl as version 6.2.9

Steps to Reproduce

Add dateTime control and init with formcontrol and empty value

Code Reproduction URL

https://github.com/olaisen81/ionic-datetime-issue_6.3.1

Ionic Info

Ionic:

Ionic CLI : 6.17.1 (C:\Users\fabio.perfetti\AppData\Roaming\npm\node_modules@ionic\cli)
Ionic Framework : @ionic/angular 6.3.1
@angular-devkit/build-angular : 14.2.5
@angular-devkit/schematics : 14.2.5
@angular/cli : 14.2.5
@ionic/angular-toolkit : 6.1.0

Capacitor:

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

Utility:

cordova-res : 0.15.1
native-run : 1.7.1

System:

NodeJS : v14.18.0 (C:\Program Files\nodejs\node.exe)
npm : 6.14.15
OS : Windows 10

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Oct 13, 2022
@olaisen81 olaisen81 changed the title bug: Datetime show 0 Days when initilized with FormControl and string empty value bug: Datetime show 0 Days when initialized with FormControl and string empty value Oct 13, 2022
@liamdebeasi liamdebeasi self-assigned this Oct 13, 2022
@liamdebeasi liamdebeasi changed the title bug: Datetime show 0 Days when initialized with FormControl and string empty value bug: datetime header shows 0 days selected with no value even if multiple="false" Oct 13, 2022
@liamdebeasi liamdebeasi added package: core @ionic/core package type: bug a confirmed bug report labels Oct 13, 2022
@ionitron-bot ionitron-bot bot removed the triage label Oct 13, 2022
@liamdebeasi
Copy link
Contributor

Thanks for the report. I can reproduce this. Here is a dev build if you are interested in testing the proposed fix:

npm install @ionic/angular@6.3.2-dev.11665667373.1a3ecede

@liamdebeasi liamdebeasi removed their assignment Oct 13, 2022
@liamdebeasi
Copy link
Contributor

This has been resolved via #26120, and a fix will be available in an upcoming release of Ionic Framework. Feel free to continue testing this dev build, and let me know if you run into any issues.

@olaisen81
Copy link
Author

Thanks for the report. I can reproduce this. Here is a dev build if you are interested in testing the proposed fix:

npm install @ionic/angular@6.3.2-dev.11665667373.1a3ecede

Hi Liam, after the fix header showing current date correctly ('Thu 13 Oct' in locale it) but the button for selecting months and years showing May 2021 instead of October 2022.

@liamdebeasi
Copy link
Contributor

liamdebeasi commented Oct 13, 2022

This is unrelated to the dev build, but still something we can fix. I'll dig into this a bit more.

@liamdebeasi
Copy link
Contributor

liamdebeasi commented Oct 14, 2022

Here is a dev build that should fix the header issue:

npm install @ionic/angular@6.3.2-dev.11665761572.1e49d325

The problem here is your FormControl for the datetime is initialized to the empty string. Datetime was trying to parse that as an ISO 8601 date, but it was not valid.

Typically the solution here would be to initialize the FormControl to undefined, but there is some old code in Ionic Angular that converts undefined or null values to the empty string:

this.el.nativeElement.value = this.lastValue = value == null ? '' : value;

As a result, I changed datetime to treat the empty string like it does not have a value at all. Note that this is temporary and will change in Ionic 7 when we remove the old Ionic Angular conversion code. As a result, you may want to update your implementation now to use undefined instead of the empty string.

@liamdebeasi
Copy link
Contributor

I merged #26131 which as a fix for the empty string bug. This fix should be available in an upcoming release of Ionic.

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 16, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: bug a confirmed bug report
Projects
None yet
2 participants