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): selected option not being highlighted when options are added asynchronously #2499

Merged
merged 4 commits into from Jan 13, 2017

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Jan 2, 2017

Fixes the select component not highlighting the model value when the options get added after initialization.

Fixes #2497.

@crisbeto crisbeto requested a review from kara January 2, 2017 14:55
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jan 2, 2017
Copy link
Member

@devversion devversion left a comment

Choose a reason for hiding this comment

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

Nice. I was also playing with it and also ran into the Expression has changed [..] issue.

Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

Some nits, then should be good to merge

@@ -1235,6 +1255,33 @@ class NgIfSelect {
}


@Component({
selector: 'ng-if-select',
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy paste error? Looks like the selector is the same as the component above.

</md-select>
`
})
class SelectWithoutOptions {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This name is a bit misleading, since it does have options. How about SelectInitWithoutOptions or something?

if (this._control) {
// Defer setting the value in order to avoid the "Expression has changed after
// it was checked" errors from Angular.
Promise.resolve(null).then(() => this.writeValue(this._control.value));
Copy link
Contributor

@kara kara Jan 4, 2017

Choose a reason for hiding this comment

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

I think what you're looking for is this._setSelectionByValue(this._control.value). writeValue should only really be used by the forms API.

@crisbeto
Copy link
Member Author

crisbeto commented Jan 4, 2017

Thanks for the feedback @kara, it's addressed.

Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

LGTM

@kara
Copy link
Contributor

kara commented Jan 12, 2017

@crisbeto Can you rebase? When you're done, apply the merge label so we know it's ready :)

…dded asynchronously

Fixes the select component not highlighting the model value when the options get added after initialization.

Fixes angular#2497.
@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker and removed pr: needs rebase labels Jan 12, 2017
@crisbeto crisbeto removed their assignment Jan 12, 2017
@tinayuangao tinayuangao merged commit 7fc38b9 into angular:master Jan 13, 2017
@kara kara mentioned this pull request Jan 24, 2017
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: md-select doesn't set selected value if options are initialized after the model
5 participants