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

[Bug Report][3.4.2] Autocomplete initial value #18737

Closed
JChrist opened this issue Nov 21, 2023 · 8 comments · Fixed by #18766
Closed

[Bug Report][3.4.2] Autocomplete initial value #18737

JChrist opened this issue Nov 21, 2023 · 8 comments · Fixed by #18766
Assignees
Labels
C: VAutocomplete VAutocomplete T: bug Functionality that does not work as intended/expected
Milestone

Comments

@JChrist
Copy link

JChrist commented Nov 21, 2023

Environment

Vuetify Version: 3.4.2
Last working version: 2.7.1
Vue Version: 3.3.8
Browsers: Chrome 119.0.0.0
OS: Linux x86_64

Steps to reproduce

  1. Create a v-autocomplete component, binding a model value with an initial value that does not match any item from the items.
  2. The autocomplete component will render initially showing the invalid value.

Expected Behavior

The Autocomplete should discard the non-matching initial value, as it is not contained in the items

Actual Behavior

The Autocomplete component renders with the invalid initial value.

Reproduction Link

https://play.vuetifyjs.com/#...

Other comments

This functionality was useful in order to bind an empty element to the component (such as empty string). The component would render properly without containing the empty value (the label would stay down, same as not binding any model value).

I can see in the migration guide that this is included and described as a behavior change:

v-model values not present in items will now be rendered instead of being ignored.

However, I cannot seem to find any way to restore this behavior.

@KaelWD
Copy link
Member

KaelWD commented Nov 27, 2023

Not a bug - #4000

@KaelWD
Copy link
Member

KaelWD commented Nov 27, 2023

such as empty string

#16372

@johnleider
Copy link
Member

Would this be documentation related @KaelWD ?

@yuwu9145
Copy link
Member

yuwu9145 commented Nov 29, 2023

  • My understanding of the conclusion for #4000 is it isn't a bug, which means model shouldn't hold any value that doesn't exist in items
  • But #16372 says empty string is a legit value that can make input dirty, even it's not in the list, which means v-model in this case can hold a value that doesn't exist in items.

If my understandings were correct, conclusions from these two issues are contradictive. And screenshot gif does show a inconsistent symptom

"Once blurred, empty string isn't legit anymore"

Therefore, need a final decision of "Are select/autocomplate allowed to show any value that doesn't exist in the items"?

test-test

@KaelWD
Copy link
Member

KaelWD commented Nov 29, 2023

My understanding of the conclusion for #4000 is it isn't a bug

We implemented it as a behaviour change in v3

@yuwu9145
Copy link
Member

yuwu9145 commented Nov 30, 2023

Ok, that makes sense. Now the conclusion lands as arbitrary v-model should be respected as input display values, except for null or undefined.

But, issue shown in above gif still valid. I will amend my PR to respect '' during blur

@johnleider johnleider added this to the v3.4.x milestone Dec 4, 2023
@yuwu9145
Copy link
Member

yuwu9145 commented Dec 5, 2023

@JChrist null or undefined should be used as initial empty binding values

@johnleider
Copy link
Member

@JChrist null or undefined should be used as initial empty binding values

Please add an alert about this information on the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VAutocomplete VAutocomplete T: bug Functionality that does not work as intended/expected
Projects
None yet
4 participants