diff --git a/src/app/components/autocomplete/autocomplete.ts b/src/app/components/autocomplete/autocomplete.ts index 6dace6205bd..86411498abe 100755 --- a/src/app/components/autocomplete/autocomplete.ts +++ b/src/app/components/autocomplete/autocomplete.ts @@ -880,7 +880,15 @@ 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( + @Inject(DOCUMENT) private document: Document, + 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()); }); @@ -1368,12 +1376,11 @@ export class AutoComplete implements AfterViewChecked, AfterContentInit, OnDestr } else { if (this.focusedOptionIndex() !== -1) { this.onOptionSelect(event, this.visibleOptions()[this.focusedOptionIndex()]); + event.preventDefault(); } this.hide(); } - - event.preventDefault(); } onEscapeKey(event) {