primevue
primevue copied to clipboard
Autocomplete: Correctly typed input stays string instead of turning into an object
Describe the bug
When selecting any item from the list Autocomplete with objects works nice, however the problem starts when someone modifies the input. The ref variable stays string instead of becoming an object.
Reproducer
https://stackblitz.com/edit/primevue-create-vue-issue-template-zgsrkr?file=src%2FApp.vue,package.json
PrimeVue version
3.47.2
Vue version
3.x
Language
TypeScript
Build / Runtime
Vite
Browser(s)
ALL
Steps to reproduce the behavior
- Type United Kingdom and select United Kingdom from the dropdown list - selectedCountry is then an object
- Now remove last m letter and type it back
- Do not click on the item from the dropdown list but click outside the autocomplete component - selectedCountry stays string
Note that I am using in the example forceSelection prop.
Expected behavior
Even after modifying an input, if the input is correct (its typed value is in the dropdown list) I would expect the string to turn into an object when going out of focus.
Thanks a lot for your report! I set a milestone for it. We'll check it before the milestone is released.
When the input does not match any suggestions' object, it will remain a string and will turn into an empty string when the blur event occurs. This is expected behavior.