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: ionCheck and ionUncheck for ion-checkbox #19097

Closed

Conversation

mahnuh
Copy link

@mahnuh mahnuh commented Aug 14, 2019

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?

Issue Number: #19096

What is the new behavior?

  • added ionCheck event to ion-checkbox which will be emitted when the checkbox is being checked
  • added ionUncheck event to ion-checkbox which will be emitted when the checkbox is being unchecked

Does this introduce a breaking change?

  • Yes
  • No

Other information

--

@ionitron-bot ionitron-bot bot added package: angular @ionic/angular package package: core @ionic/core package labels Aug 14, 2019
@mahnuh mahnuh marked this pull request as ready for review August 14, 2019 12:53
@brandyscarney
Copy link
Member

Thank you for the PR! The checked property is provided in the detail of the ionChange event. Is there a reason you can't check for this?

const checkbox = document.querySelector('ion-checkbox');

checkbox.addEventListener('ionChange', (ev) => {
  console.log('Checked changed', ev.detail.checked);
});

Here's a Codepen example: https://codepen.io/brandyscarney/pen/ExYKaaX?editors=1011

@mahnuh
Copy link
Author

mahnuh commented Aug 15, 2019

Hey @brandyscarney,
sure, ionChange would work in most cases but as described in #19096 there are some cases where it doesn't. Basically when you want to determine if either the checked property changed because the user tapped on the checkbox or the model just changed. This is not possible with ionChange I guess, as it will be emitted in both cases?

@Gorgoroth
Copy link

@brandyscarney I agree, it makes sense to emit the checked and unchecked events. It's easy to do in this place, it's harder to handle the case of #19096 in business logic.

@mahnuh
Copy link
Author

mahnuh commented Aug 28, 2019

@brandyscarney just wondering if there are any updates on this?

@mahnuh mahnuh mentioned this pull request Oct 1, 2019
13 tasks
@averyjohnston
Copy link
Contributor

Thanks for the PR! We appreciate the work you've put in. In the time that's passed, we've slated some changes for the upcoming Ionic 7 release that will solve the problems this PR is targeting. Namely, the ionChange event is being modified to only fire for user-committed changes.

Here is the RFC for this change in general: #25532
And here is the PR for ion-checkbox in particular, which has already been merged into the v7.0 branch and will be available in the upcoming major release: #25923

As such, I'm going to go ahead and close this PR out. Thank you!

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.

4 participants