diff --git a/src/app/components/autocomplete/autocomplete.ts b/src/app/components/autocomplete/autocomplete.ts index 86411498abe..1796f9496bd 100755 --- a/src/app/components/autocomplete/autocomplete.ts +++ b/src/app/components/autocomplete/autocomplete.ts @@ -1108,12 +1108,12 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr this.updateModel(query); } - if (query.length === 0 && !this.multiple) { + if (query.length === 0 && !this.multiple && !this.completeOnFocus) { this.onClear.emit(); setTimeout(() => { this.hide(); - }, this.delay / 2); + }); } else { if (query.length >= this.minLength) { this.focusedOptionIndex.set(-1); @@ -1155,6 +1155,7 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr if (!this.dirty && this.completeOnFocus) { this.search(event, event.target.value, 'focus'); + this.show(); } this.dirty = true; this.focused = true; @@ -1465,8 +1466,8 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr return; } - //do not search blank values on input change - if (source === 'input' && query.trim().length === 0) { + //do not search on input change if minLength is not met + if (source === 'input' && query.trim().length < this.minLength) { return; } this.loading = true; diff --git a/src/app/components/overlay/overlay.ts b/src/app/components/overlay/overlay.ts index 2d2e02a7b51..6d13ee08d48 100644 --- a/src/app/components/overlay/overlay.ts +++ b/src/app/components/overlay/overlay.ts @@ -524,16 +524,15 @@ export class Overlay implements AfterContentInit, OnDestroy { case 'void': if (!this.visible) { this.hide(container, true); - } - - this.unbindListeners(); + this.modalVisible = false; + this.unbindListeners(); - DomHandler.appendOverlay(this.overlayEl, this.targetEl, this.appendTo); - ZIndexUtils.clear(container); - this.modalVisible = false; - this.cd.markForCheck(); + DomHandler.appendOverlay(this.overlayEl, this.targetEl, this.appendTo); + ZIndexUtils.clear(container); + this.cd.markForCheck(); - break; + break; + } } this.handleEvents('onAnimationDone', event); @@ -546,6 +545,7 @@ export class Overlay implements AfterContentInit, OnDestroy { } bindListeners() { + this.unbindListeners(); this.bindScrollListener(); this.bindDocumentClickListener(); this.bindDocumentResizeListener();