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: ForceSelection does not force selection - formControl value is changed even without selection #14389

Closed
kkoripl opened this issue Dec 18, 2023 · 0 comments · Fixed by #14398
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@kkoripl
Copy link

kkoripl commented Dec 18, 2023

Describe the bug

When at Autocomplete we'll set flag: forceSelection = true, it was expected that below formControl value will change only after actual selection of a value from the client - especially if it's dropdown. Though, the value is changed on every key press and also nullified just a split second after selecting proper value, to, after that, being set properly.

Environment

Found at: PrimeNg v16.9.1 + Angular: 16.2.12
Recreated at: PrimeNg v17.1.0 + Angular: 17.0.2

Probably it was introduced at v16.7.0 when acccessibility changes.

Reproducer

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

Angular version

17.0.2

PrimeNG version

17.1.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18.6.0+

Browser(s)

No response

Steps to reproduce the behavior

  1. Start typing i.e. Germany while looking into console, letters will arrive.
  2. Select the country
  3. Look into console, there will be null record added after letters and then the country object.

Expected behavior

In console, there will be just one record with filtered country object. So it means valueChanges will be invoked only once - at country selection.

Probably whole thing is done by this difference (missing flag check):
image

Cause then the updateModel actually calls onModelChange, which earlier on was only called after flag check:
image

I don't know if this is just a mistake or a change made with a reason, that I need to prepare my app for.

@kkoripl kkoripl added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 18, 2023
kkoripl pushed a commit to kkoripl/primeng that referenced this issue Dec 19, 2023
kkoripl pushed a commit to kkoripl/primeng that referenced this issue Dec 19, 2023
@cetincakiroglu cetincakiroglu added this to the 17.1.1 milestone Dec 20, 2023
@cetincakiroglu cetincakiroglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Dec 20, 2023
cetincakiroglu added a commit that referenced this issue Dec 20, 2023
Fix #14389: ForceSelection does not force selection - formControl value is changed even without selection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
2 participants