Skip to content

feat(select): add compareWith property - #17358

Merged
liamdebeasi merged 19 commits into
ionic-team:masterfrom
zakton5:feat-select-track-by
Mar 1, 2019
Merged

liamdebeasi merged 19 commits into
ionic-team:masterfrom
zakton5:feat-select-track-by

Conversation

@zakton5

@zakton5 zakton5 commented Feb 1, 2019

Copy link
Copy Markdown
Contributor

Short description of what this resolves:

Using objects as values was only supported by comparing object equality (===) but not by content. This PR adds a compareWith property that accepts a property name (ie id) or a function of the shape (o1, o2) => boolean that is used to determine equality.

Changes proposed in this pull request:

  • Add compareWith prop
  • Move internal option comparison logic to its own function: compareOptions

Ionic Version: 4.0.0

Fixes: #14598

@ionitron-bot ionitron-bot Bot added package: angular @ionic/angular package package: core @ionic/core package labels Feb 1, 2019
@zakton5 zakton5 changed the title Feat select track by feat(select): add compareWith property Feb 1, 2019
@remisture

Copy link
Copy Markdown

ETA for this?

@zakton5

zakton5 commented Feb 15, 2019

Copy link
Copy Markdown
Contributor Author

@remisture 🤷‍♂️ Whenever the Ionic team reviews it. Hard to say..

@brandyscarney

Copy link
Copy Markdown
Member

Thank you for the PR!

I have this added to review for 4.1.0. We were working out the process for how we would move forward with features so we haven't been adding them, but we are now! Although I'd almost consider this a fix as it's a regression. I have added myself and some other coworkers to review this.

My only request at first glance is could you please move the test out of the preview/ folder - maybe we could change the basic test? We're planning to remove the preview folders that's why I ask. 🙂

@zakton5

zakton5 commented Feb 27, 2019

Copy link
Copy Markdown
Contributor Author

Will do @brandyscarney!

@liamdebeasi liamdebeasi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking really good so far!

Comment thread core/src/components/select/select.tsx Resolved
@brandyscarney

Copy link
Copy Markdown
Member

Thank you @zakton5 !

@zakton5
zakton5 deleted the feat-select-track-by branch March 3, 2019 23:24
franmosteiro pushed a commit to laRivolta/daChecklist that referenced this pull request Mar 9, 2019
if (typeof compareWith === 'function') {
return compareWith(currentValue, compareValue);
} else if (typeof compareWith === 'string') {
return currentValue[compareWith] === compareValue[compareWith];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This object comparison using a string is not null-safe. It doesn't check for the currentValue/compareValue to be set nor being an object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: angular @ionic/angular package package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants