Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete: Down/Up arrows trigger (onSelect) event when [autoHighlight]="true" #15208

Closed
ninjavis opened this issue Mar 31, 2024 · 3 comments · Fixed by #15210
Closed

Autocomplete: Down/Up arrows trigger (onSelect) event when [autoHighlight]="true" #15208

ninjavis opened this issue Mar 31, 2024 · 3 comments · Fixed by #15210
Labels
LTS-16-PORTABLE Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@ninjavis
Copy link

Describe the bug

As the title indicates, the arrow buttons no longer work for selecting an autocomplete option. It immediately triggers the (onSelect) event when [autoHighlight]="true".

The below code works:

<p-autoComplete
      formControlName="selectedCountry"
      [suggestions]="filteredCountries"
      (onSelect)="selecter($event.value)"
      (completeMethod)="filterCountry($event)"
      field="name"
    ></p-autoComplete>

The code below does not:

<p-autoComplete
      [autoHighlight]="true"
      formControlName="selectedCountry"
      [suggestions]="filteredCountries"
      (onSelect)="selecter($event.value)"
      (completeMethod)="filterCountry($event)"
      field="name"
    ></p-autoComplete>

Environment

Win 11
Angular CLI: 17.3.2
Node: 18.16.1
Package Manager: npm 9.5.1
OS: win32 x64

Angular: 17.3.1
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.1703.2
@angular-devkit/build-angular 17.3.2
@angular-devkit/core 17.3.2
@angular-devkit/schematics 17.3.2
@angular/cdk 13.3.4
@angular/cli 17.3.2
@schematics/angular 17.3.2
rxjs 7.8.1
typescript 5.4.3
zone.js 0.14.4

primeng 17.12.0

Reproducer

https://stackblitz.com/edit/hzfsyn?file=src%2Fapp%2Fdemo%2Fautocomplete-reactive-forms-demo.ts,src%2Fapp%2Fdemo%2Fautocomplete-reactive-forms-demo.html

Angular version

17.3.2

PrimeNG version

17.12.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18.16.1

Browser(s)

Opera One 108.0.5067.29

Steps to reproduce the behavior

As described, merely add [autoHighlight]="true" to the p-autoComplete component.
Search for autocomplete suggestions.
Press the down arrow on the keyboard to try and select an option.
You'll see that the (onSelect) event fires, which it shouldn't, because this event is often used for POST/PATCH API calls.

Expected behavior

The arrow buttons should not trigger the p-autoComplete (onSelect) event.

@ninjavis ninjavis added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Mar 31, 2024
@maruthumj
Copy link
Contributor

@ninjavis I will start work on this

@RanjithkumarRajendran
Copy link

Is this fix can support Primeng Version 16.9.1?

Issue is same:
As described, merely add [autoHighlight]="true" to the p-autoComplete component.
Search for autocomplete suggestions.
Press the down arrow on the keyboard to try and select an option.
You'll see that the (onSelect) event fires, which it shouldn't, because this event is often used for POST/PATCH API calls.

if we are making AutoHighlight as false, On Down arrow, system is not showing the highlighted one.

@cetincakiroglu cetincakiroglu added this to the 17.14.0 milestone Apr 18, 2024
@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working LTS-16-PORTABLE and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Apr 18, 2024
cetincakiroglu added a commit that referenced this issue Apr 18, 2024
Bug #15208 - Autocomplete: Down/Up arrows trigger (onSelect) event when [autoHighlight]="true"
@ninjavis
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTS-16-PORTABLE Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
4 participants