-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
fix(select): selected option not being highlighted when options are added asynchronously #2499
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.
Nice. I was also playing with it and also ran into the Expression has changed [..]
issue.
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.
Some nits, then should be good to merge
@@ -1235,6 +1255,33 @@ class NgIfSelect { | |||
} | |||
|
|||
|
|||
@Component({ | |||
selector: 'ng-if-select', |
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.
Copy paste error? Looks like the selector is the same as the component above.
</md-select> | ||
` | ||
}) | ||
class SelectWithoutOptions { |
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.
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)); |
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.
I think what you're looking for is this._setSelectionByValue(this._control.value)
. writeValue
should only really be used by the forms API.
Thanks for the feedback @kara, it's addressed. |
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.
LGTM
@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.
7506973
to
5c5351f
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Fixes the select component not highlighting the model value when the options get added after initialization.
Fixes #2497.