fix(VAutocomplete): do not emit update:search on blur-triggered reset#22771
Open
mixelburg wants to merge 1 commit intovuetifyjs:masterfrom
Open
fix(VAutocomplete): do not emit update:search on blur-triggered reset#22771mixelburg wants to merge 1 commit intovuetifyjs:masterfrom
mixelburg wants to merge 1 commit intovuetifyjs:masterfrom
Conversation
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 vuetifyjs#22767
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #22767
Problem
When using
v-model:searchto power remote data fetching, selecting an item and clicking outside triggers a spuriousupdate:searchevent with''. This reloads the items list with an empty query, removing the selected item from the list and breaking the displayed value.Root Cause
searchwas declared asuseProxiedModel(props, 'search', ''), which automatically emitsupdate:searchwheneversearch.valuechanges. TheisFocusedwatcher unconditionally setssearch.value = ''on blur, triggering the emit even though no user input occurred.Fix
Replace
useProxiedModelforsearchwith a private_searchshallowRef + computed accessor. Only emitupdate:searchwhenisFocusedis true (matching the existing guard already used for menu/isPristine management). External prop changes are synced via a dedicatedwatch(() => props.search)watcher.