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

fix(select): make select with no options return undefined when OK is pressed #11968

Merged
merged 2 commits into from
Jun 8, 2017
Merged

fix(select): make select with no options return undefined when OK is pressed #11968

merged 2 commits into from
Jun 8, 2017

Conversation

zakton5
Copy link
Contributor

@zakton5 zakton5 commented Jun 7, 2017

Short description of what this resolves:

Opening a select without options in it and then pressing Okay resulted in the bound model being set to {}

Changes proposed in this pull request:

The current code instantiates an empty object and attempts to put values of any text inputs in that object. I've added a check to determine if that object has any properties in it and, if it does not, it returns undefined instead of that empty object.

Ionic Version:3.x

Fixes: #10435

@@ -322,7 +322,9 @@ export class AlertCmp {
this.d.inputs.forEach(i => {
values[i.name] = i.value;
});
return values;

Copy link
Contributor

Choose a reason for hiding this comment

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

could we implement this with an early return instead?

if (this.d.inputs.length === 0) {
  return undefined;
}

this way we don't allocate values and Object.keys()'s array.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that sounds like a better idea. I'll commit that soon.

Copy link
Contributor Author

@zakton5 zakton5 left a comment

Choose a reason for hiding this comment

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

@manucorporat Does this look good?

@manucorporat manucorporat merged commit dc6c586 into ionic-team:master Jun 8, 2017
@manucorporat
Copy link
Contributor

Merged!!! thanks a lot for the PR! @zakton5 !!

@zakton5 zakton5 deleted the select-empty-object-fix branch June 8, 2017 12:57
@zakton5
Copy link
Contributor Author

zakton5 commented Jun 8, 2017

No problem :) @manucorporat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants