diff --git a/src/app/components/autocomplete/autocomplete.ts b/src/app/components/autocomplete/autocomplete.ts index 6dace6205bd..9687bc41837 100755 --- a/src/app/components/autocomplete/autocomplete.ts +++ b/src/app/components/autocomplete/autocomplete.ts @@ -880,7 +880,14 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr return typeof this.modelValue() === 'string' && this.optionValue; } - constructor(@Inject(DOCUMENT) private document: Document, public el: ElementRef, public renderer: Renderer2, public cd: ChangeDetectorRef, public config: PrimeNGConfig, public overlayService: OverlayService, private zone: NgZone) { + constructor( + public el: ElementRef, + public renderer: Renderer2, + public cd: ChangeDetectorRef, + public config: PrimeNGConfig, + public overlayService: OverlayService, + private zone: NgZone + ) { effect(() => { this.filled = ObjectUtils.isNotEmpty(this.modelValue()); }); @@ -1100,12 +1107,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); @@ -1147,6 +1154,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; @@ -1458,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();