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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

compareWith for RadioControlValueAccessor #28486

Open
sclausen opened this issue Feb 1, 2019 · 6 comments
Open

compareWith for RadioControlValueAccessor #28486

sclausen opened this issue Feb 1, 2019 · 6 comments
Labels
area: forms feature: under consideration Feature request for which voting has completed and the request is now under consideration feature Issue that requests a new feature freq1: low
Milestone

Comments

@sclausen
Copy link

sclausen commented Feb 1, 2019

馃殌 feature request

Relevant Package

This feature request is for @angular/forms

Description

I want to bind objects to radio button values and need an own function for comparing the ngModel with the value.

Describe the solution you'd like

I suggest the RadioControlValueAccessor should have compareWith like the SelectControlValueAccessor.

Describe alternatives you've considered

@ngbot ngbot bot added this to the needsTriage milestone Feb 1, 2019
@kara
Copy link
Contributor

kara commented Feb 5, 2019

@sclausen can you add some more detail to this? suggested use, etc

@kara kara added the feature Issue that requests a new feature label Feb 5, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Feb 5, 2019
@kara kara added the freq1: low label Feb 5, 2019
@sclausen
Copy link
Author

sclausen commented Feb 7, 2019

@kara If I provide an object as my [(ngModel)] and want to have the radio button's [value] to be an object too, the radio button directive never marks the radio as checked, since it compares by strict equality.

If this lines could be copied to the radio_control_value_accessor.ts and writeValue could be changed to the following, it would be easy to implement a custom function to check the identity.

  writeValue(value: any): void {
    this._state = this._compareWith(this.value, value);
    this._renderer.setProperty(this._elementRef.nativeElement, 'checked', this._state);
  }

I would've provided a PR, but don't know how to write a test case for this.

@adam-marshall
Copy link

adam-marshall commented Sep 23, 2019

I need this too. I am using [compareWith] for select controls, but there is no equivalent way of getting this to work with radio buttons.

The justification is the same as the following issues, but for radio buttons instead of select:
#13268 (comment)
#13295
#12742
https://stackoverflow.com/questions/40325480/angular2-ngmodel-ngvalue-select-option-object-equality-across-different-instan

Therefore it would probably be intuitive for radio_control_value_accessor.ts to use the same pattern?

@adam-marshall
Copy link

There is a related issue on material which this would resolve too: angular/components#10495

@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Jun 4, 2021
@angular-robot
Copy link
Contributor

angular-robot bot commented Jun 4, 2021

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@angular-robot
Copy link
Contributor

angular-robot bot commented Jun 24, 2021

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

@angular-robot angular-robot bot added the feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors label Jun 24, 2021
@AndrewKushnir AndrewKushnir added feature: under consideration Feature request for which voting has completed and the request is now under consideration and removed feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature: votes required Feature request which is currently still in the voting phase labels Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: forms feature: under consideration Feature request for which voting has completed and the request is now under consideration feature Issue that requests a new feature freq1: low
Projects
None yet
Development

No branches or pull requests

5 participants