Skip to content

fix(VSelect, VAutocomplete, VCombobox): default modelValue to undefined - #23097

Open
waterWang wants to merge 1 commit into
vuetifyjs:masterfrom
waterWang:fix/22126-vselect-null-default-modelvalue
Open

fix(VSelect, VAutocomplete, VCombobox): default modelValue to undefined#23097
waterWang wants to merge 1 commit into
vuetifyjs:masterfrom
waterWang:fix/22126-vselect-null-default-modelvalue

Conversation

@waterWang

Copy link
Copy Markdown
Contributor

Description

When VSelect, VAutocomplete, or VCombobox is used without explicitly passing v-model, the default modelValue was null. This caused a null-valued option in the items list to be unintentionally pre-selected, because useProxiedModel treats null as a valid value (not undefined), so it falls back to the default null rather than the empty array.

Root Cause

In all three components, the modelValue prop default was set to null:

modelValue: null,

useProxiedModel checks props[prop] !== undefined to decide whether to use the external value or the default. Since null !== undefined is true, the internal value became null instead of the expected empty array [].

Fix

Changed the default from null to undefined. When no v-model is provided:

  • props.modelValue is undefined
  • useProxiedModel falls back to the defaultValue (empty array [])
  • No null-valued option is pre-selected

When v-model="null" is explicitly passed, the behavior is unchanged — the option with value: null is still correctly selected.

Related Issues

Fixes #22126

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug Report][3.10.3] VSelect / VAutocomplete default modelValue is null instead of undefined, causing unintended selection of null-valued item

1 participant