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): presentation time emits ionChange once #24968

Merged
merged 6 commits into from
Mar 22, 2022
Merged

Conversation

sean-perkins
Copy link
Contributor

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?

When modifying the value of an ion-datetime[presentation="time"] with the picker wheel visible in the viewport; the datetime component will emit 4 ionChange events, resulting in an incorrect value and in Angular, an incorrect display of the picker wheel.

For example, when setting the value to 06:02:40, the emitted events will be:

{ value: '06:02:40' }
{ value: '2022-03-20T06:57:00-04:00' }
{ value: '2022-03-20T00:02:00-04:00' }
{ value: '00:02' }

This corresponds to:

  • The first emission is the ion-datetime watch callback for the value being modified/ionChange.
  • The second emission is the ion-picker-column-internal hour column detecting a change/modifying the value.
  • The third emission is the ion-picker-column-internal minute column detecting a change/modifying the value.
  • The fourth emission is the ion-picker-column-internal am/pm column detecting a change/modifying the value.

Issue URL: #24967

What is the new behavior?

ion-datetime[presentation="time"] will only emit a single ionChange event when the value is modified, regardless if the picker wheel is visible in the viewport or not.

This results in the value correctly reflecting the new datetime value and the display of the component to be correct.

The ion-picker-column-internal will not emit ionChange events when the value is modified externally. It will only emit change events as a result of selecting a new value or the fallback setting the initial value.

Does this introduce a breaking change?

  • Yes
  • No

Other information

@sean-perkins sean-perkins requested a review from a team as a code owner March 20, 2022 06:27
@github-actions github-actions bot added the package: core @ionic/core package label Mar 20, 2022
@sean-perkins sean-perkins changed the title fix(datetime): presentation time only emits ionChange once on change fix(datetime): presentation time emits ionChange once Mar 20, 2022
el.scrollTo(0, 300);
});

expect(ionChangeSpy).not.toHaveReceivedEvent();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
expect(ionChangeSpy).not.toHaveReceivedEvent();
expect(ionChangeSpy).toHaveReceivedEvent();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch, I also needed to wait for the event:

await ionChangeSpy.next();

expect(ionChangeSpy).toHaveReceivedEvent();

Confirmed this test passed with the changes and failed against main. I'll wait for CI before finally merging.

Copy link
Contributor

@liamdebeasi liamdebeasi left a comment

Choose a reason for hiding this comment

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

Good to merge once test is fixed

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.

2 participants