From 882089edaf1fffbef5d85ea96d1fb38770f2be33 Mon Sep 17 00:00:00 2001 From: Janik Schumacher Date: Fri, 2 Aug 2024 13:25:34 +0200 Subject: [PATCH] fix(autocomplete): enter keypress event --- src/app/components/autocomplete/autocomplete.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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) {