Skip to content

fix(datetime): time picker display matches dynamically set value #25010

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

Merged
merged 34 commits into from
Apr 15, 2022

Conversation

sean-perkins
Copy link
Contributor

@sean-perkins sean-perkins commented Mar 28, 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)
  • 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?

If you have a ion-datetime with presentation="time" and the initial value is in the "PM" and you attempt to update the value to "AM", the value will not update correctly.

This is caused by the working parts not being updated when the value changes. The working parts are used for generating the available hour options, which will include the value being offset by 12, if the value is PM vs. AM. When dynamically setting the value, these options were not being generated correctly, so the resulting set of available hours would not match the current value and our fallback to scroll to the "zero" item would fire, updating the value to "12" PM.

Issue URL: #24967

What is the new behavior?

When updating the value of the datetime, the time picker will correctly display the value.

  • The working parts am/pm representation is updated to be in-sync with the current value.
  • The available hour options are generated based on the current value am/pm

Does this introduce a breaking change?

  • Yes
  • No

Other information

Dev build: 6.0.15-dev.11649352526.165b8639

@sean-perkins sean-perkins requested a review from a team March 28, 2022 16:58
@github-actions github-actions bot added the package: core @ionic/core package label Mar 28, 2022
@sean-perkins sean-perkins removed the request for review from a team March 31, 2022 21:10
@averyjohnston
Copy link
Contributor

Would it make sense here to post an updated dev build in the original issue? Wanted to check on that before I review since I noticed an old version of this PR didn't solve things for the OP.

@sean-perkins
Copy link
Contributor Author

sean-perkins commented Apr 7, 2022

Would it make sense here to post an updated dev build in the original issue? Wanted to check on that before I review since I noticed an old version of this PR didn't solve things for the OP.

I can 👍 the stackblitz example there were using was also pointing to the latest, not the dev build (but the dev build contents have changed since then).

The Playwright test is checking each condition (AM->AM, AM-PM, PM-AM, PM->PM) x20, so I do feel confident in the behavior more than with our puppeteer tests x4 execution.

@sean-perkins
Copy link
Contributor Author

Dev build verified by issue reporter: #24967 (comment)

Copy link
Contributor

@averyjohnston averyjohnston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not worrying about the cropped screenshots since you have that other PR up to fix those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants