Skip to content

bug: nested ion-checkbox inside ion-radio-group does not work #27492

Closed as not planned

Description

@DavidStrausz

Prerequisites

Ionic Framework Version

v7.x

Current Behavior

When nesting an ion-checkbox inside an ion-radio-group alongside ion-radio elements the checkbox cannot be checked/unchecked.

Expected Behavior

The checkbox should keep working as usual. In v6 this was working, also e.g. ion-toggle works.

Steps to Reproduce

  1. Run reproduction
  2. Select "Grapes" in the radio-group
  3. Try to check/uncheck the checkbox

Code Reproduction URL

https://github.com/DavidStrausz/modern-input-test

Ionic Info

Ionic:

   Ionic CLI                     : 7.1.1 (C:\Users\dstrauss\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 7.0.6
   @angular-devkit/build-angular : 15.2.8
   @angular-devkit/schematics    : 15.2.8
   @angular/cli                  : 15.2.8
   @ionic/angular-toolkit        : 9.0.0

Capacitor:

   Capacitor CLI      : 5.0.3
   @capacitor/android : not installed
   @capacitor/core    : 5.0.3
   @capacitor/ios     : not installed

Utility:

   cordova-res : 0.15.4
   native-run  : 1.7.2

System:

   NodeJS : v18.12.1 (C:\Program Files\nodejs\node.exe)
   npm    : 9.4.1
   OS     : Windows 10

Additional Information

I'm using @ionic/angular

Activity

  1. liamdebeasi commented on May 17, 2023

    @liamdebeasi
    Contributor

    Thanks for the report. Can you clarify why you are using checkboxes inside of a radio group? The documentation states that radios should be used inside of a radio group.

  2. added
    needs: reply
    on May 17, 2023
  3. DavidStrausz commented on May 17, 2023

    @DavidStrausz
    ContributorAuthor

    @liamdebeasi Thanks for your answer! Oh, I am using radios in the radio group, in some cases I just display an additonal checkbox directly below the selected radio option (like in the reprodution example).

    Our specific use-case is a a radio group where the user can select how they want to pay (credit-card, paypal, etc.), and for some of these options we offer the possibility to save the payment method, so it can be used without entering the details again, this is done using a checkbox which is available below some of the options when they are selected.

    We could just swap the checkboxes for toggles, as these do work as expected, but seems like it should work for all inputs, as it has through ionic versions 1-6.

  4. added and removed
    needs: reply
    on May 17, 2023
  5. liamdebeasi commented on May 30, 2023

    @liamdebeasi
    Contributor

    It looks like this behavior change is related to a6b2629#diff-480c2b0a087c089851e16f28f69d728afc0bfbddf1b5c19b0b8ee07bd072c24b.

    ion-toggle works because the check/uncheck behavior is handled in an click event callback on the host.
    ion-checkbox listens for the change event from the underlying input element.

    ion-radio-group calls ev.preventDefault() when a click happens which prevents the native input inside of ion-checkbox from being checked/unchecked (which is the default browser behavior). I need to check with the team to see if there's a specific reason why we need to listen for change over click.

  6. liamdebeasi commented on Aug 9, 2023

    @liamdebeasi
    Contributor

    Going to merge this with #27169. As part of the work for the linked ticket we plan to update ion-checkbox to listen for click events instead of the native change event. This should avoid the behavior reported here.

  7. ionitron-bot commented on Sep 8, 2023

    @ionitron-bot

    Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. 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.

  8. locked and limited conversation to collaborators on Sep 8, 2023
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

    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