Skip to content

Commit

Permalink
fix(autocomplete): panel not resetting properly when entering wrong v…
Browse files Browse the repository at this point in the history
…alue

This fixes a regression caused by the changes from 880e6d5 which prevented the panel from closing and reopening in certain cases.

Fixes angular#5910.
  • Loading branch information
crisbeto committed Jul 20, 2017
1 parent 23ec30f commit bee5f83
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/lib/autocomplete/autocomplete-trigger.ts
Expand Up @@ -198,23 +198,23 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy {

/** Closes the autocomplete suggestion panel. */
closePanel(): void {
if (!this.panelOpen) {
return;
}

if (this._overlayRef && this._overlayRef.hasAttached()) {
this._overlayRef.detach();
this._closingActionsSubscription.unsubscribe();
}

this._panelOpen = false;
this._resetPlaceholder();

// We need to trigger change detection manually, because
// `fromEvent` doesn't seem to do it at the proper time.
// This ensures that the placeholder is reset when the
// user clicks outside.
this._changeDetectorRef.detectChanges();
if (this._panelOpen) {
this._panelOpen = false;

// We need to trigger change detection manually, because
// `fromEvent` doesn't seem to do it at the proper time.
// This ensures that the placeholder is reset when the
// user clicks outside.
this._changeDetectorRef.detectChanges();
}
}

/**
Expand Down

0 comments on commit bee5f83

Please sign in to comment.