Skip to content

Commit bee5f83

Browse files
committed
fix(autocomplete): panel not resetting properly when entering wrong value
This fixes a regression caused by the changes from 880e6d5 which prevented the panel from closing and reopening in certain cases. Fixes #5910.
1 parent 23ec30f commit bee5f83

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/lib/autocomplete/autocomplete-trigger.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,23 +198,23 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
198198

199199
/** Closes the autocomplete suggestion panel. */
200200
closePanel(): void {
201-
if (!this.panelOpen) {
202-
return;
203-
}
204201

205202
if (this._overlayRef && this._overlayRef.hasAttached()) {
206203
this._overlayRef.detach();
207204
this._closingActionsSubscription.unsubscribe();
208205
}
209206

210-
this._panelOpen = false;
211207
this._resetPlaceholder();
212208

213-
// We need to trigger change detection manually, because
214-
// `fromEvent` doesn't seem to do it at the proper time.
215-
// This ensures that the placeholder is reset when the
216-
// user clicks outside.
217-
this._changeDetectorRef.detectChanges();
209+
if (this._panelOpen) {
210+
this._panelOpen = false;
211+
212+
// We need to trigger change detection manually, because
213+
// `fromEvent` doesn't seem to do it at the proper time.
214+
// This ensures that the placeholder is reset when the
215+
// user clicks outside.
216+
this._changeDetectorRef.detectChanges();
217+
}
218218
}
219219

220220
/**

0 commit comments

Comments
 (0)