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: ngModel value changes to null before selecting when forceSelection is true #15880

Open
OmkarJ13 opened this issue Jun 21, 2024 · 0 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@OmkarJ13
Copy link

OmkarJ13 commented Jun 21, 2024

Describe the bug

When [forceSelection] is enabled on the autocomplete component, when selecting a value the model changes to null for a split second before changing to the selected value. This leads to some weird bugs if the DOM is updated depending upon the autocomplete value.

Environment

Stackblitz

Reproducer

https://stackblitz.com/edit/xckznk?file=src%2Fapp%2Fautocomplete-force-selection-demo.html,src%2Fapp%2Fautocomplete-force-selection-demo.ts,src%2Findex.html

Angular version

18.0.1

PrimeNG version

17.18.1

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

v18.20.3

Browser(s)

No response

Steps to reproduce the behavior

  1. Go to the stack blitz
  2. Click on the autocomplete and select "Country 1"
  3. You should see a paragraph come up above the autocomplete.
  4. Now edit the autocomplete value to remove the "1" and try to click on "Country 2". It will not work because the value got changed to null on blur and DOM updated accordingly, but the actual click did not happen on the dropdown due to a change in its position.

Expected behavior

The component should not set the model value to null before selecting a value when forceSelection is true.

If I use OnSelect event, I don't get the null which is expected. when using ngModel or reactive forms the similar behaviour should be there.

@OmkarJ13 OmkarJ13 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

1 participant