Skip to content

feat: ionCheck and ionUncheck for ion-checkbox #19096

Closed

Description

@mahnuh

Feature Request

Ionic version:
[x] 4.x

Describe the Feature Request
I want to be able to trigger something when a checkbox is being checked/unchecked. ionChange does not work in some cases, see additional context below.

Describe Preferred Solution
Extend events on ion-checkbox to have ionCheck and ionUncheck, similar to ionSelect and ionDeselect on ion-radio.

Related Code
Working on a PR at the moment.

Additional Context
Let's say I have a list of items. Those items are custom components with a couple of checkboxes each. The data for this list comes from an observable I subscribed to. I use ionChange to detect if one of those checkboxes is being checked/unchecked and the previously mentioned observable is being triggered. This triggers ionChange again which then triggers the observable which then triggers ionChange... and now I am trapped in a pretty nasty endless loop.
I guess there could be more cases when you do not want do use ionChange to determine if a specific checkbox is being checked/unchecked.

Activity

  1. Sacrekin commented on Aug 15, 2019

    @Sacrekin

    With Vue, I made it work with the @click.native event. Basically, Checkboxes need a click event in ionic.
    <IonCheckboxVue v-model="user.check[index].val" @click.native="unCheckBoxes(index)"></IonCheckboxVue>

  2. mahnuh commented on Aug 15, 2019

    @mahnuh
    Author

    Yes, that is kind of what I did with my pull request.

  3. averyrousseau commented on Feb 2, 2022

    @averyrousseau
    Contributor

    Hello, thanks for the issue. We have another issue here #20106 to track the bug with the infinite loop on ionChange. I know it's been a while, but if that one is resolved, would that take care of your use case? Or was there anything else preventing you from using ionChange and checking the checked property?

  4. added
    needs: reply
    on Feb 2, 2022
  5. ionitron-bot commented on Feb 16, 2022

    @ionitron-bot

    Thanks for the issue! This issue is being closed due to the lack of a reply. 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.

    Thank you for using Ionic!

  6. locked and limited conversation to collaborators on Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: reply

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions