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

fix(datetime): empty string is treated as no value #26131

Merged
merged 8 commits into from Oct 17, 2022

Conversation

liamdebeasi
Copy link
Member

@liamdebeasi liamdebeasi commented Oct 14, 2022

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)
    • Some docs updates need to be made in the ionic-docs repo, in a separate PR. See the contributing guide for details.
  • Build (npm run build) was run locally and any changes were pushed
  • Lint (npm run lint) has passed locally and any fixes were made for failures

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue URL: resolves #26116 (comment)

The problem in the reported issue was that the author was initializing the value of ion-datetime to the empty string. The component would then try to parse the empty string as an ISO-8601 date and fail.

Normally, the solution would have been to set the value to undefined, but there is old code in Ionic Angular that converts null or undefined values to the empty string, so that solution would not have worked:

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

What is the new behavior?

  • For now, ion-datetime will treat the empty string as if it did not have a value.
  • Once this lands, I will create a PR for Ionic v7 that removes both the old code and this behavior.

Does this introduce a breaking change?

  • Yes
  • No

Other information

@github-actions github-actions bot added package: angular @ionic/angular package package: core @ionic/core package labels Oct 14, 2022
@liamdebeasi liamdebeasi changed the title Datetime empty string fix(datetime): empty string is treated as no valud Oct 14, 2022
@liamdebeasi liamdebeasi changed the title fix(datetime): empty string is treated as no valud fix(datetime): empty string is treated as no value Oct 14, 2022
@liamdebeasi liamdebeasi marked this pull request as ready for review October 14, 2022 15:43
@liamdebeasi liamdebeasi requested a review from a team as a code owner October 14, 2022 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: angular @ionic/angular package package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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