@@ -72,7 +72,7 @@ export const makeVComboboxProps = propsFactory({
72
72
delimiters : Array as PropType < readonly string [ ] > ,
73
73
74
74
...makeFilterProps ( { filterKeys : [ 'title' ] } ) ,
75
- ...makeSelectProps ( { hideNoData : true , returnObject : true } ) ,
75
+ ...makeSelectProps ( { hideNoData : false , returnObject : true } ) ,
76
76
...omit ( makeVTextFieldProps ( {
77
77
modelValue : null ,
78
78
role : 'combobox' ,
@@ -127,6 +127,7 @@ export const VCombobox = genericComponent<new <
127
127
const isFocused = shallowRef ( false )
128
128
const isPristine = shallowRef ( true )
129
129
const listHasFocus = shallowRef ( false )
130
+ const showAllItemsForNoMatch = shallowRef ( false )
130
131
const vMenuRef = ref < VMenu > ( )
131
132
const vVirtualScrollRef = ref < VVirtualScroll > ( )
132
133
const selectionIndex = shallowRef ( - 1 )
@@ -194,6 +195,9 @@ export const VCombobox = genericComponent<new <
194
195
if ( props . hideSelected ) {
195
196
return filteredItems . value . filter ( filteredItem => ! model . value . some ( s => s . value === filteredItem . value ) )
196
197
}
198
+ if ( filteredItems . value . length === 0 && showAllItemsForNoMatch . value ) {
199
+ return items . value
200
+ }
197
201
return filteredItems . value
198
202
} )
199
203
@@ -214,6 +218,7 @@ export const VCombobox = genericComponent<new <
214
218
const label = toRef ( ( ) => menu . value ? props . closeText : props . openText )
215
219
216
220
watch ( _search , value => {
221
+ showAllItemsForNoMatch . value = false
217
222
if ( cleared ) {
218
223
// wait for clear to finish, VTextField sets _search to null
219
224
// then search computed triggers and updates _search to ''
@@ -222,6 +227,7 @@ export const VCombobox = genericComponent<new <
222
227
menu . value = true
223
228
}
224
229
230
+ isPristine . value = ! value
225
231
emit ( 'update:search' , value )
226
232
} )
227
233
@@ -439,16 +445,22 @@ export const VCombobox = genericComponent<new <
439
445
}
440
446
} )
441
447
442
- watch ( menu , ( ) => {
443
- if ( ! props . hideSelected && menu . value && model . value . length ) {
448
+ watch ( menu , val => {
449
+ if ( ! props . hideSelected && val && model . value . length ) {
444
450
const index = displayItems . value . findIndex (
445
451
item => model . value . some ( s => ( props . valueComparator || deepEqual ) ( s . value , item . value ) )
446
452
)
447
453
IN_BROWSER && window . requestAnimationFrame ( ( ) => {
448
454
index >= 0 && vVirtualScrollRef . value ?. scrollToIndex ( index )
449
455
} )
450
456
}
451
- } )
457
+
458
+ if ( val && search . value && filteredItems . value . length === 0 ) {
459
+ showAllItemsForNoMatch . value = true
460
+ }
461
+
462
+ isPristine . value = ! search . value
463
+ } , { immediate : true } )
452
464
453
465
watch ( ( ) => props . items , ( newVal , oldVal ) => {
454
466
if ( menu . value ) return
@@ -536,7 +548,6 @@ export const VCombobox = genericComponent<new <
536
548
{ ! displayItems . value . length && ! props . hideNoData && ( slots [ 'no-data' ] ?.( ) ?? (
537
549
< VListItem key = "no-data" title = { t ( props . noDataText ) } />
538
550
) ) }
539
-
540
551
< VVirtualScroll ref = { vVirtualScrollRef } renderless items = { displayItems . value } itemKey = "value" >
541
552
{ ( { item, index, itemRef } ) => {
542
553
const itemProps = mergeProps ( item . props , {
@@ -692,7 +703,7 @@ export const VCombobox = genericComponent<new <
692
703
'append-inner' : ( ...args ) => (
693
704
< >
694
705
{ slots [ 'append-inner' ] ?.( ...args ) }
695
- { ( ! props . hideNoData || props . items . length ) && props . menuIcon ? (
706
+ { props . menuIcon ? (
696
707
< VIcon
697
708
class = "v-combobox__menu-icon"
698
709
color = { vTextFieldRef . value ?. fieldIconColor }
0 commit comments