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

feat(input): ionChange will only emit from user committed changes #25858

Merged
merged 27 commits into from
Sep 12, 2022

Conversation

sean-perkins
Copy link
Contributor

@sean-perkins sean-perkins commented Aug 30, 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?

ionChange is emitted from both internal and external value changes of ion-input.

Angular

  • ion-input form control value updates when ionChange is emitted (ngModel, formControl, formControlName).

Issue URL: Resolves #20106, #20061

What is the new behavior?

  • ionChange will only be emitted from user committed changes to ion-input:
    • User types within the control and the control is blurred/loses focus
    • User clicks the clear action in an input with an existing value
  • ionChange will not be emitted from externally assigning a value to ion-input

Angular

  • ion-input form control value updates when ionInput is emitted (ngModel, formControl, formControlName).

Does this introduce a breaking change?

  • Yes
  • No

Developers that need the immediate value of the input as the user types should migrate their implementations to using ionInput instead.

Developers that assign a value directly to ion-input should not expect ionChange to be emitted. In these cases, developers should execute expected side-effect behavior when assigning the value.

Other information

This is the first component being resolved of this issue. As others are migrated, we will likely have a "Form controls" section in the BREAKING doc, instead of copy/pasting for each affected component.

Once all of the components of a specific value accessor are migrated, the temporary value accessors will be removed and the legacy class name will be the same API.

Dev-build: 6.2.4-dev.11661977223.1d42c906

@github-actions github-actions bot added the package: core @ionic/core package label Aug 30, 2022
@github-actions github-actions bot added the package: angular @ionic/angular package label Aug 31, 2022
@sean-perkins sean-perkins marked this pull request as ready for review August 31, 2022 20:18
@sean-perkins sean-perkins requested a review from a team as a code owner August 31, 2022 20:18
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.

The changes look good, though I am not sure I understand the purpose of the value accessor updates.

@sean-perkins
Copy link
Contributor Author

General note surrounding the value accessors. I compared against using input with ngModel in an isolated Angular application. In that example, ngModelChange is emitted whenever the input event was raised (as the user types). This also updates the control's value when used in a form.

To match this pattern with the change in behavior to ionChange, we are migrating to listening to ionInput instead to offer the same experience.

core/src/components/input/input.tsx Outdated Show resolved Hide resolved
core/src/components/input/input.tsx Outdated Show resolved Hide resolved
core/src/components/input/input.tsx Show resolved Hide resolved
core/src/components/input/input.tsx Outdated Show resolved Hide resolved
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.

Great job!

@sean-perkins sean-perkins changed the title fix(input): ionChange will only emit from user committed changes feat(input): ionChange will only emit from user committed changes Sep 9, 2022
BREAKING.md Outdated Show resolved Hide resolved
Co-authored-by: Liam DeBeasi <liamdebeasi@users.noreply.github.com>
@sean-perkins sean-perkins merged commit 8732b7b into feature-7.0 Sep 12, 2022
@sean-perkins sean-perkins deleted the FW-2032 branch September 12, 2022 19:35
liamdebeasi added a commit that referenced this pull request Apr 11, 2023
<!-- Please refer to our contributing documentation for any questions on
submitting a pull request, or let us know here if you need any help:
https://ionicframework.com/docs/building/contributing -->

<!-- Some docs updates need to be made in the `ionic-docs` repo, in a
separate PR. See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#modifying-documentation
for details. -->

<!-- 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. -->


<!-- Issues are required for both bug fixes and features. -->
Unbuilt changes in `core` are not always being caught because the
`api.txt` file is not cached.

Stencil will potentially update both the `src/components.d.ts` and
`api.txt` files when there are built changes to the public API. We need
to check both files when accounting for unbuilt changes.

Example: #25858

This had updates to `api.txt` that were not built.

Built changes PR:
#25933

Example of this change catching `api.txt` changes as intended:
#27165

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

- GitHub Actions core build step caches `api.txt`

## 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. -->
liamdebeasi added a commit that referenced this pull request Apr 17, 2023
<!-- Please refer to our contributing documentation for any questions on
submitting a pull request, or let us know here if you need any help:
https://ionicframework.com/docs/building/contributing -->

<!-- Some docs updates need to be made in the `ionic-docs` repo, in a
separate PR. See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#modifying-documentation
for details. -->

<!-- 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. -->


<!-- Issues are required for both bug fixes and features. -->
Unbuilt changes in `core` are not always being caught because the
`api.txt` file is not cached.

Stencil will potentially update both the `src/components.d.ts` and
`api.txt` files when there are built changes to the public API. We need
to check both files when accounting for unbuilt changes.

Example: #25858

This had updates to `api.txt` that were not built.

Built changes PR:
#25933

Example of this change catching `api.txt` changes as intended:
#27165

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

- GitHub Actions core build step caches `api.txt`

## 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. -->
liamdebeasi added a commit that referenced this pull request Apr 19, 2023
<!-- Please refer to our contributing documentation for any questions on
submitting a pull request, or let us know here if you need any help:
https://ionicframework.com/docs/building/contributing -->

<!-- Some docs updates need to be made in the `ionic-docs` repo, in a
separate PR. See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#modifying-documentation
for details. -->

<!-- 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. -->


<!-- Issues are required for both bug fixes and features. -->
Unbuilt changes in `core` are not always being caught because the
`api.txt` file is not cached.

Stencil will potentially update both the `src/components.d.ts` and
`api.txt` files when there are built changes to the public API. We need
to check both files when accounting for unbuilt changes.

Example: #25858

This had updates to `api.txt` that were not built.

Built changes PR:
#25933

Example of this change catching `api.txt` changes as intended:
#27165

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

- GitHub Actions core build step caches `api.txt`

## 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. -->
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.

None yet

3 participants