You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: nested ion-checkbox inside ion-radio-group does not work #27492
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.
@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.
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.
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.
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.
Activity
liamdebeasi commentedon May 17, 2023
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.
DavidStrausz commentedon May 17, 2023
@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.
liamdebeasi commentedon May 30, 2023
It looks like this behavior change is related to a6b2629#diff-480c2b0a087c089851e16f28f69d728afc0bfbddf1b5c19b0b8ee07bd072c24b.
ion-toggleworks because the check/uncheck behavior is handled in anclickevent callback on the host.ion-checkboxlistens for thechangeevent from the underlyinginputelement.ion-radio-groupcallsev.preventDefault()when a click happens which prevents the nativeinputinside ofion-checkboxfrom 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 forchangeoverclick.liamdebeasi commentedon Aug 9, 2023
Going to merge this with #27169. As part of the work for the linked ticket we plan to update
ion-checkboxto listen for click events instead of the nativechangeevent. This should avoid the behavior reported here.ionitron-bot commentedon Sep 8, 2023
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.