From a9e77fb9101ab8efb261951d1c5a8f8af0fd23f9 Mon Sep 17 00:00:00 2001 From: Maks Pikov Date: Fri, 27 Mar 2026 22:10:24 +0000 Subject: [PATCH] fix(VAutocomplete): do not emit update:search on blur-triggered reset When isFocused transitions to false, the watcher unconditionally sets search.value = '', which was being forwarded through useProxiedModel as an update:search event. Users relying on update:search to fetch remote items would then get an empty search, reloading their items list and losing the current selection. Replace useProxiedModel for search with a private _search shallowRef + a computed accessor, and only emit update:search when isFocused is true (same guard already used for menu/isPristine management). External prop changes are synced in via a dedicated watch(() => props.search) watcher. Fixes #22767 --- .../VAutocomplete/VAutocomplete.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/vuetify/src/components/VAutocomplete/VAutocomplete.tsx b/packages/vuetify/src/components/VAutocomplete/VAutocomplete.tsx index 27e5abd3db4..474501a6daa 100644 --- a/packages/vuetify/src/components/VAutocomplete/VAutocomplete.tsx +++ b/packages/vuetify/src/components/VAutocomplete/VAutocomplete.tsx @@ -120,7 +120,7 @@ export const VAutocomplete = genericComponent true, }, - setup (props, { slots }) { + setup (props, { emit, slots }) { const { t } = useLocale() const vTextFieldRef = ref() const isFocused = shallowRef(false) @@ -133,7 +133,13 @@ export const VAutocomplete = genericComponent vTextFieldRef.value?.color) const { InputIcon } = useInputIcon(props) - const search = useProxiedModel(props, 'search', '') + const _search = shallowRef(props.search ?? '') + const search = computed({ + get: () => _search.value, + set: (val: string | null) => { + _search.value = val ?? '' + }, + }) const model = useProxiedModel( props, 'modelValue', @@ -426,6 +432,16 @@ export const VAutocomplete = genericComponent { + if (!isFocused.value || isSelecting.value) return + + emit('update:search', val) + }) + + watch(() => props.search, val => { + _search.value = val ?? '' + }) + watch(search, val => { if (!isFocused.value || isSelecting.value) return