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(autocomplete): close panel when options list is empty #2834

Merged
merged 1 commit into from
Jan 31, 2017

Conversation

kara
Copy link
Contributor

@kara kara commented Jan 27, 2017

Ready for review.

r: @jelbourn @andrewseguin

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jan 27, 2017
Copy link
Contributor

@andrewseguin andrewseguin left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -131,7 +134,7 @@ export class MdAutocompleteTrigger implements AfterContentInit, ControlValueAcce
* A stream of actions that should close the autocomplete panel, including
* when an option is selected and when the backdrop is clicked.
*/
get panelClosingActions(): Observable<any> {
get panelClosingActions(): Observable<MdOptionSelectEvent | null> {
Copy link
Member

Choose a reason for hiding this comment

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

What's your reasoning for doing | null here since we haven't been doing explicit null yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just thought we should start so that it's more explicit. It's not super important to change in this PR, so I can revert for now.

@@ -149,6 +152,11 @@ export class MdAutocompleteTrigger implements AfterContentInit, ControlValueAcce
return this._keyManager.activeItem as MdOption;
}

/** The initial list of autocomplete options, as soon as the zone has stabilized */
get initialOptionList(): Observable<QueryList<MdOption>> {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is really the initial list of options- it's just whatever the next list of options are once the zone stabilizes; the fact that you call it on initialization is separate from what you're getting. So you could change this to _getStableOptions and then in the subscribe function do

let initialOptions = this._getStableOptions();`

Also should be private or internal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. Will do.

@@ -149,6 +152,11 @@ export class MdAutocompleteTrigger implements AfterContentInit, ControlValueAcce
return this._keyManager.activeItem as MdOption;
}

/** The initial list of autocomplete options, as soon as the zone has stabilized */
get initialOptionList(): Observable<QueryList<MdOption>> {
return this._zone.onStable.first().map(() => this.autocomplete.options);
Copy link
Member

Choose a reason for hiding this comment

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

Add comment explaining why you need to do this

fixture.detectChanges();

fixture.whenStable().then(() => {
// Filter down the option list so no options match the value
Copy link
Member

Choose a reason for hiding this comment

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

"so" => "such that"

@kara
Copy link
Contributor Author

kara commented Jan 31, 2017

@jelbourn Comments addressed.

@kara kara added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Jan 31, 2017
@kara kara merged commit 8449ef4 into angular:autocomplete Jan 31, 2017
kara added a commit to kara/material2 that referenced this pull request Feb 3, 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.

4 participants