Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions packages/vuetify/src/components/VAutocomplete/VAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const VAutocomplete = genericComponent<new <
'update:menu': (value: boolean) => true,
},

setup (props, { slots }) {
setup (props, { emit, slots }) {
const { t } = useLocale()
const vTextFieldRef = ref<VTextField>()
const isFocused = shallowRef(false)
Expand All @@ -133,7 +133,13 @@ export const VAutocomplete = genericComponent<new <
const { items, transformIn, transformOut } = useItems(props)
const { textColorClasses, textColorStyles } = useTextColor(() => vTextFieldRef.value?.color)
const { InputIcon } = useInputIcon(props)
const search = useProxiedModel(props, 'search', '')
const _search = shallowRef<string>(props.search ?? '')
const search = computed<string>({
get: () => _search.value,
set: (val: string | null) => {
_search.value = val ?? ''
},
})
const model = useProxiedModel(
props,
'modelValue',
Expand Down Expand Up @@ -426,6 +432,16 @@ export const VAutocomplete = genericComponent<new <
}
})

watch(_search, val => {
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

Expand Down
Loading