Skip to content

Commit

Permalink
Fix for #15281
Browse files Browse the repository at this point in the history
  • Loading branch information
LoaderB0T committed Aug 1, 2024
1 parent d204e64 commit f72af89
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
18 changes: 13 additions & 5 deletions src/app/components/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions src/app/components/overlay/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -546,6 +545,7 @@ export class Overlay implements AfterContentInit, OnDestroy {
}

bindListeners() {
this.unbindListeners();
this.bindScrollListener();
this.bindDocumentClickListener();
this.bindDocumentResizeListener();
Expand Down

0 comments on commit f72af89

Please sign in to comment.