Autocomplete: ForceSelection does not force selection - formControl value is changed even without selection #14389
Labels
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Milestone
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
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](https://private-user-images.githubusercontent.com/37674650/291302287-bdd12150-8db9-41e7-807d-2d3237f65b67.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5OTIwNDgsIm5iZiI6MTczODk5MTc0OCwicGF0aCI6Ii8zNzY3NDY1MC8yOTEzMDIyODctYmRkMTIxNTAtOGRiOS00MWU3LTgwN2QtMmQzMjM3ZjY1YjY3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDA1MTU0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTMwOTJhMTczNWIwZmU3MzlmNjI0NGQ3MDkxODA1N2M4MTBmMzEwYmFhNGU4ODljZmIwZDlkZTZmYTMxMWQyMmMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.O_pS2sjnK1cHHT-d27KT1JP1SHUlsOd7p8sgSMNFcXU)
Cause then the updateModel actually calls onModelChange, which earlier on was only called after flag check:
![image](https://private-user-images.githubusercontent.com/37674650/291302513-367d321b-c8c2-4b4c-b44d-e9443c787bfd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5OTIwNDgsIm5iZiI6MTczODk5MTc0OCwicGF0aCI6Ii8zNzY3NDY1MC8yOTEzMDI1MTMtMzY3ZDMyMWItYzhjMi00YjRjLWI0NGQtZTk0NDNjNzg3YmZkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDA1MTU0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTkwZGEyODU2OWFlNjI2YTMzMGM4NjM2N2JkNGJhNDEwODAzNGY4Y2YzMDY2YjhiOTU1YTY5ZWRiZTViMmM3MWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.PvRb7TapIOCHLvIw-36QZlL2-opPcHfMFhXUQsgYclY)
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.
The text was updated successfully, but these errors were encountered: