primefaces / primeng

The Most Complete Angular UI Component Library
https://primeng.org
Other
10.46k stars 4.6k forks source link

AutoComplete with forceSelection enabled has unwanted behavior #13633

Open NejcSmid opened 1 year ago

NejcSmid commented 1 year ago

Describe the bug

Hi,

We are using the Angular AutoComplete component with the forceSelection property set to true. The component is inside a form and includes a required validator. When the user starts typing, suggestions appear. The issue specifically arises when the user clicks on a suggestion in the dropdown. At this point, the forceSelection property first clears the value (since focus is on the dropdown), then a validation message appears due to the field being required, and finally, the selected value appears. This behavior is quite annoying as it causes a momentary UI blink.

Do you have any suggestions for a temporary fix?

Regards, Nejc

Environment

Windows 11 Enterprise (22H2), Angular 16.2.3, PrimeNG 16.2.0

Reproducer

No response

Angular version

16.2.3

PrimeNG version

16.2.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

0.0.0.

Browser(s)

Firefox 117.0

Steps to reproduce the behavior

No response

Expected behavior

Force selection is not triggered if the autocomplete input control loses focus, but the dropdown is still in focus.

arthurvergacas commented 7 months ago

This bug also causes the onClear emitter to fire when clicking on an option, which in our case also caused some unexpected behavior.