@@ -128,7 +128,6 @@ export const VCombobox = genericComponent<new <
128
128
const isFocused = shallowRef ( false )
129
129
const isPristine = shallowRef ( true )
130
130
const listHasFocus = shallowRef ( false )
131
- const showAllItemsForNoMatch = shallowRef ( false )
132
131
const vMenuRef = ref < VMenu > ( )
133
132
const vVirtualScrollRef = ref < VVirtualScroll > ( )
134
133
const selectionIndex = shallowRef ( - 1 )
@@ -190,27 +189,19 @@ export const VCombobox = genericComponent<new <
190
189
: ( props . multiple ? model . value . length : search . value . length )
191
190
} )
192
191
193
- const { filteredItems, getMatches } = useFilter ( props , items , search )
194
-
195
- const hasMatchingItems = computed ( ( ) => {
196
- return props . hideSelected
197
- ? filteredItems . value . some ( filteredItem => ! model . value . some ( s => s . value === filteredItem . value ) )
198
- : filteredItems . value . length > 0
199
- } )
192
+ const { filteredItems, getMatches } = useFilter ( props , items , ( ) => isPristine . value ? '' : search . value )
200
193
201
194
const displayItems = computed ( ( ) => {
202
195
if ( props . hideSelected ) {
203
196
return filteredItems . value . filter ( filteredItem => ! model . value . some ( s => s . value === filteredItem . value ) )
204
197
}
205
- if ( filteredItems . value . length === 0 && showAllItemsForNoMatch . value ) {
206
- return items . value
207
- }
208
198
return filteredItems . value
209
199
} )
210
200
211
- const menuDisabled = computed ( ( ) => {
212
- return form . isReadonly . value || form . isDisabled . value
213
- } )
201
+ const menuDisabled = computed ( ( ) => (
202
+ ( props . hideNoData && ! displayItems . value . length ) ||
203
+ form . isReadonly . value || form . isDisabled . value
204
+ ) )
214
205
const _menu = useProxiedModel ( props , 'menu' )
215
206
const menu = computed ( {
216
207
get : ( ) => _menu . value ,
@@ -224,18 +215,14 @@ export const VCombobox = genericComponent<new <
224
215
const { menuId, ariaExpanded, ariaControls, ariaLabel } = useMenuActivator ( props , menu )
225
216
226
217
watch ( _search , value => {
227
- showAllItemsForNoMatch . value = false
228
218
if ( cleared ) {
229
219
// wait for clear to finish, VTextField sets _search to null
230
220
// then search computed triggers and updates _search to ''
231
221
nextTick ( ( ) => ( cleared = false ) )
232
222
} else if ( isFocused . value && ! menu . value ) {
233
- menu . value = hasMatchingItems . value || ! props . hideNoData
234
- } else if ( isFocused . value && menu . value && ! hasMatchingItems . value && props . hideNoData ) {
235
- menu . value = false
223
+ menu . value = true
236
224
}
237
225
238
- isPristine . value = ! value
239
226
emit ( 'update:search' , value )
240
227
} )
241
228
@@ -453,22 +440,16 @@ export const VCombobox = genericComponent<new <
453
440
}
454
441
} )
455
442
456
- watch ( menu , val => {
457
- if ( ! props . hideSelected && val && model . value . length ) {
443
+ watch ( menu , ( ) => {
444
+ if ( ! props . hideSelected && menu . value && model . value . length ) {
458
445
const index = displayItems . value . findIndex (
459
446
item => model . value . some ( s => ( props . valueComparator || deepEqual ) ( s . value , item . value ) )
460
447
)
461
448
IN_BROWSER && window . requestAnimationFrame ( ( ) => {
462
449
index >= 0 && vVirtualScrollRef . value ?. scrollToIndex ( index )
463
450
} )
464
451
}
465
-
466
- if ( val && search . value && ! hasMatchingItems . value ) {
467
- showAllItemsForNoMatch . value = true
468
- }
469
-
470
- isPristine . value = ! search . value
471
- } , { immediate : true } )
452
+ } )
472
453
473
454
watch ( items , ( newVal , oldVal ) => {
474
455
if ( menu . value ) return
@@ -560,6 +541,7 @@ export const VCombobox = genericComponent<new <
560
541
{ ! displayItems . value . length && ! props . hideNoData && ( slots [ 'no-data' ] ?.( ) ?? (
561
542
< VListItem key = "no-data" title = { t ( props . noDataText ) } />
562
543
) ) }
544
+
563
545
< VVirtualScroll ref = { vVirtualScrollRef } renderless items = { displayItems . value } itemKey = "value" >
564
546
{ ( { item, index, itemRef } ) => {
565
547
const itemProps = mergeProps ( item . props , {
@@ -715,7 +697,7 @@ export const VCombobox = genericComponent<new <
715
697
'append-inner' : ( ...args ) => (
716
698
< >
717
699
{ slots [ 'append-inner' ] ?.( ...args ) }
718
- { props . menuIcon ? (
700
+ { ( ! props . hideNoData || props . items . length ) && props . menuIcon ? (
719
701
< VIcon
720
702
class = "v-combobox__menu-icon"
721
703
color = { vTextFieldRef . value ?. fieldIconColor }
0 commit comments