Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix(select): allow ngOptions to be set in $timeout #10203

Closed
wants to merge 1 commit into from

Conversation

ajohnston256
Copy link

Fix angular 1.3 regression where empty string was shown

Closes #9714

Fix angular 1.3 regression where empty string was shown

Closes angular#9714
@googlebot
Copy link

CLAs look good, thanks!

@Narretz Narretz added this to the 1.3.5 milestone Nov 23, 2014
if (this.hasOption(value)) {
delete optionsMap[value];
if (ngModelCtrl.$viewValue == value) {
if (ngModelCtrl.$viewValue == value && !anySelected) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment to explain why it is necessary to check !anySelected here?

Copy link
Author

Choose a reason for hiding this comment

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

If the expression on line 215 evaluates to true, then we execute the statement:

this.renderUnknownOption(value);

But, we should only render the unknown option if no option is currently selected. If any option is selected, the select element should only show the values defined in ngOptions.

@Narretz Narretz self-assigned this Nov 25, 2014
Narretz added a commit to Narretz/angular.js that referenced this pull request Nov 26, 2014
Otherwise, if the removed option was the empty option (value ''),
and the currently selected option had a value of 0, the select
would think that the currently selected option had been removed,
causing the unknown option to be added again.

Fixes angular#9714
Fixes angular#10115
Closes angular#10203
@Narretz
Copy link
Contributor

Narretz commented Nov 26, 2014

@ajohnston256 I looked at your solution and saw that there's a simpler fix that fixes the issue more substantially. Can you take a look at #10241?

@ajohnston256
Copy link
Author

@Narretz #10241 looks great, strict compare should solve a lot of the issues. Thanks for putting that together Narretz

Narretz added a commit to Narretz/angular.js that referenced this pull request Dec 1, 2014
Otherwise, if the removed option was the empty option (value ''),
and the currently selected option had a value of 0, the select
would think that the currently selected option had been removed,
causing the unknown option to be added again.

Fixes angular#9714
Fixes angular#10115
Closes angular#10203
@Narretz Narretz closed this in 9fa73cb Dec 1, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression using ngOptions asynchronously in angular 1.3
3 participants