-
Notifications
You must be signed in to change notification settings - Fork 13.5k
feat(select): add compareWith Input for object value comparison #11965
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @zakton5
src/components/select/select.ts
Outdated
}); | ||
} else { | ||
option.selected = this.getValues().some(selectValue => { | ||
return isCheckedProperty(selectValue, option.value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is isCheckedProperty is the default, compare function? this way we don't have to duplicate code. does it make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this what you meant? @manucorporat
src/components/select/select.ts
Outdated
this._compareWith = fn; | ||
} | ||
|
||
private _compareWith: (o1: any, o2: any) => boolean = isCheckedProperty; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you move private _compareWith: (o1: any, o2: any) => boolean = isCheckedProperty;
just below _text: string = '';
(line 180)? also, drop the private property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @zakton5
yeah! now looks beautiful |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manucorporat How's this?
@zakton5 looks perfect now! but I prefer to wait until next version (3.5). 3.4 is scheduled for next wednesday. |
Alright, thanks for your help! |
Thanks a lot for the PR!! |
@manucorporat No problem! Thanks for your help |
Short description of what this resolves:
Selects that use objects as values can end up with different object identities than the currently selected object, resulting in blank selects. More details provided in Angular link below.
Changes proposed in this pull request:
Leverage the same principle used in Angular's compareWith
Ionic Version: 3.x
Fixes: #6625
Sorry about the multiple commits