@@ -368,7 +368,7 @@ export default defineComponent({
368
368
}
369
369
} else if (props .modelValue !== undefined && props .modelValue !== null ) {
370
370
if (props .valueAttribute ) {
371
- const option = props . options .find (option => option [props .valueAttribute ] === props .modelValue )
371
+ const option = options . value .find (option => option [props .valueAttribute ] === props .modelValue )
372
372
return option ? option [props .optionAttribute ] : null
373
373
} else {
374
374
return [' string' , ' number' ].includes (typeof props .modelValue ) ? props .modelValue : props .modelValue [props .optionAttribute ]
@@ -452,18 +452,24 @@ export default defineComponent({
452
452
)
453
453
})
454
454
455
- const debouncedSearch = typeof props .searchable === ' function' ? useDebounceFn (props .searchable , props .debounce ) : undefined
455
+ const debouncedSearch = props . searchable && typeof props .searchable === ' function' ? useDebounceFn (props .searchable , props .debounce ) : undefined
456
456
457
- const filteredOptions = computedAsync (async () => {
457
+ const options = computedAsync (async () => {
458
458
if (props .searchable && debouncedSearch ) {
459
459
return await debouncedSearch (query .value )
460
460
}
461
461
462
- if (query .value === ' ' ) {
463
- return props .options
462
+ return props .options || []
463
+ }, [], {
464
+ lazy: props .searchableLazy
465
+ })
466
+
467
+ const filteredOptions = computed (() => {
468
+ if (! query .value ) {
469
+ return options .value
464
470
}
465
471
466
- return ( props . options as any []) .filter ((option : any ) => {
472
+ return options . value .filter ((option : any ) => {
467
473
return (props .searchAttributes ?.length ? props .searchAttributes : [props .optionAttribute ]).some ((searchAttribute : any ) => {
468
474
if ([' string' , ' number' ].includes (typeof option )) {
469
475
return String (option ).search (new RegExp (query .value , ' i' )) !== - 1
@@ -474,8 +480,6 @@ export default defineComponent({
474
480
return child !== null && child !== undefined && String (child ).search (new RegExp (query .value , ' i' )) !== - 1
475
481
})
476
482
})
477
- }, [], {
478
- lazy: props .searchableLazy
479
483
})
480
484
481
485
const createOption = computed (() => {
0 commit comments