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: Add ion-radio-group compareWith property #18943

Closed
WimWidgets opened this issue Jul 30, 2019 · 10 comments
Closed

feat: Add ion-radio-group compareWith property #18943

WimWidgets opened this issue Jul 30, 2019 · 10 comments
Labels
package: core @ionic/core package type: feature request a new feature, enhancement, or improvement

Comments

@WimWidgets
Copy link

Feature Request

Ionic version:
[x] 4.x

Describe the Feature Request
Support for using objects as values for ion-radio elements within an ion-radio-group and having the default value checked.

Describe Preferred Solution
Add a compareWith property to ion-radio-group just like on ion-select.

Additional Context
Is there a reason the select does support this and the radio group doesn't? It seems to me both are merely different UI solutions for a similar technical use-case (select one of a list of values).

@ionitron-bot ionitron-bot bot added the triage label Jul 30, 2019
@xyboox
Copy link

xyboox commented Sep 17, 2020

I second this, for Ionic v5

@topalavlad
Copy link
Contributor

I also find this useful. I would like to try and implement it if the issue passes triage.

@capc0
Copy link
Contributor

capc0 commented Nov 4, 2021

same requirement here. Binding value to objects does not work very well without a compareWith function

@averyjohnston
Copy link
Contributor

Hi folks, thanks for the feature request. Could you explain your use case for this? I know it's been a while since this was posted, so anyone feel free to chime in.

@averyjohnston averyjohnston added the needs: reply the issue needs a response from the user label Feb 7, 2022
@ionitron-bot ionitron-bot bot removed the triage label Feb 7, 2022
@capc0
Copy link
Contributor

capc0 commented Feb 8, 2022

The current implementation is based around strict equality (https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/radio/radio.tsx#L128)

This works fine for literals, but is problematic when dealing with object references. Often enough the list of selectable radio button values is fetched from an API (lets say an array of cities [{name: 'London', country: 'UK' }, ....] and you already have the selected city {name: 'London', id: '123'} from somewhere else. Since it is not the same object reference, no radio button seems to be checked. With compareWith we can implement a function and tell that e.g. only the name property should be used for comparison which would render the radio button as selected.

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels Feb 8, 2022
@averyjohnston
Copy link
Contributor

Thanks! I talked with the team, and we agree that this would be a useful feature to have. I'm also flagging this as help wanted as this would be a good candidate for community help. If you'd like to take a stab at it, you can use ion-select's version of the feature as a starting point.

One thing to note -- there is an open PR here #24687 that addresses a bug in ion-select related to compareWith. Something to be aware of if you dive in before that's reviewed and/or merged.

@averyjohnston averyjohnston added help wanted a good issue for the community package: core @ionic/core package type: feature request a new feature, enhancement, or improvement labels Feb 8, 2022
@ionitron-bot
Copy link

ionitron-bot bot commented Feb 8, 2022

This issue has been labeled as help wanted. This label is added to issues that we believe would be good for contributors.

If you'd like to work on this issue, please comment here letting us know that you would like to submit a pull request for it. This helps us to keep track of the pull request and make sure there isn't duplicated effort.

For a guide on how to create a pull request and test this project locally to see your changes, see our contributing documentation.

Thank you!

@ionitron-bot ionitron-bot bot removed the triage label Feb 8, 2022
@liamdebeasi liamdebeasi added type: feature request a new feature, enhancement, or improvement and removed help wanted a good issue for the community type: feature request a new feature, enhancement, or improvement labels Nov 7, 2022
@jhpetersen
Copy link

I just stumbled upon this during my Ionic 3 -> Ionic 6 migration nightmare.
Can't believe that this is not priorized higher.
In Ionic 3 this was easy possible with a custom pipe on the checked property, but now in Ionic 6 one has to code extra stuff to workaround this 👎

@mapsandapps
Copy link
Contributor

Thanks for the feature request! This has been implemented in #27452 and will be released in an upcoming version of Ionic.

Copy link

ionitron-bot bot commented Dec 9, 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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Dec 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: core @ionic/core package type: feature request a new feature, enhancement, or improvement
Projects
None yet
Development

No branches or pull requests

8 participants