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 wheel picker does not auto select first item #25839

Closed
4 of 7 tasks
RRGT19 opened this issue Aug 26, 2022 · 8 comments · Fixed by #28520
Closed
4 of 7 tasks

bug: datetime wheel picker does not auto select first item #25839

RRGT19 opened this issue Aug 26, 2022 · 8 comments · Fixed by #28520
Labels
package: core @ionic/core package type: bug a confirmed bug report

Comments

@RRGT19
Copy link

RRGT19 commented Aug 26, 2022

Prerequisites

Ionic Framework Version

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

Current Behavior

When using the ion-datetime with preferWheel, I cannot choose the first date presented.

The demo above shows today date by default, if the date that the user wants to select is today, he cannot do it.

The same happens if I use a max date:

Expected Behavior

The user should be able to select the first date that is presented.

Steps to Reproduce

Implement an ion-datetime with preferWheel as is and try to select the first date available shown on the wheel.

Code Reproduction URL

https://github.com/RRGT19/ionic-test-datetime-with-no-initial-value

Ionic Info

Ionic:

   Ionic CLI                     : 6.20.1
   Ionic Framework               : @ionic/angular 6.2.5-dev.11661540078.1d2af6ea
   @angular-devkit/build-angular : 14.2.0
   @angular-devkit/schematics    : 14.2.0
   @angular/cli                  : 14.2.0
   @ionic/angular-toolkit        : 6.1.0

Capacitor:

   Capacitor CLI      : 4.1.0
   @capacitor/android : not installed
   @capacitor/core    : 4.1.0
   @capacitor/ios     : not installed

Utility:

   cordova-res : 0.15.4
   native-run  : 1.6.0

System:

   NodeJS : v16.16.0
   npm    : 8.18.0
   OS     : macOS Monterey

Additional Information

The demo repo uses the dev build 6.2.5-dev.11661540078.1d2af6ea that was provided here.

@ionitron-bot ionitron-bot bot added the triage label Aug 26, 2022
@liamdebeasi liamdebeasi changed the title bug: ion-datetime preferWheel don't allow to choose the first date presented bug: datetime wheel picker does not auto select first item Aug 29, 2022
@liamdebeasi liamdebeasi added package: core @ionic/core package type: bug a confirmed bug report labels Aug 29, 2022
@ionitron-bot ionitron-bot bot removed the triage label Aug 29, 2022
@RRGT19
Copy link
Author

RRGT19 commented Sep 12, 2022

@liamdebeasi Hi Liam, thanks for all the support so far.

Did you have time to take a look at this issue? any workaround until a complete fix is release?

@shaifulborhan
Copy link

Any updates about this issue?

Still happening in Ionic 6.3.4.

@baartho
Copy link

baartho commented Dec 20, 2022

Any updates on this issue?

Stil happening on Ionic 6.4.1.

Thanks

@fluxc
Copy link

fluxc commented Jan 10, 2023

I had the same issue looks like the date I was passing into the value was undefined. It used to work in the past but not anymore after I updated all the packages. Make sure you have a date there.
new Date().toISOString();
image

@Bishal-Vishwakarma
Copy link

Bishal-Vishwakarma commented Mar 2, 2023

@RRGT19 @baartho @shaifulborhan

The below work around worked for me:

Until this bug gets resolved we can do the following as a workaround to make this behaviour work:

ion-datetime triggers ionChange event only when there's a change in the value of ion-datetime.

  1. So, assign an empty string ("") as the default value to the variable or the formcontrol which you have used to bind with [value] of ion-datetime.
  2. set [value] of ion-datetime with the variable or the formcontrol.value
  3. Now when you click on done without interacting with the wheel type picker, you will receive the ionChange event. Bind a method to the event and check for the event.detail.value, it will come as 'undefined'. set the desired datetime (in this case, the current date) if the event.detail.value comes as undefined.

With the above steps, the default value population without interaction will work correctly without a lot of code change.

@sean-perkins

This comment was marked as outdated.

@sean-perkins
Copy link
Contributor

sean-perkins commented Nov 20, 2023

Hello everyone 👋

My previous dev-build has been updated: 7.5.7-dev.11700601905.13f94170. This includes a fix for clamping the default date parts used internally against the min/max values.

github-merge-queue bot pushed a commit that referenced this issue Dec 8, 2023
Issue number: resolves #25839

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

Confirming the working day when a datetime using a wheel picker without
an initial value will result in a value of `undefined` instead of the
displayed working day the user sees.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- `preferWheel` uses the working value on confirmation

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this introduces a breaking change, please describe the impact
and migration path for existing applications below. -->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

Dev-build: `7.5.7-dev.11701896424.13d40ac9`

Co-authored-by: liamdebeasi <liamdebeasi@users.noreply.github.com>
Copy link

ionitron-bot bot commented Jan 7, 2024

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 Jan 7, 2024
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
Development

Successfully merging a pull request may close this issue.

7 participants