5252 <label v-if =" !$slots.item" :for =" item.value" >{{ item.label }}</label >
5353 </div >
5454 <div v-if =" !filteredItems.length" class =" px-4 py-2 cursor-pointer text-lightDropdownOptionsText dark:text-darkDropdownOptionsText" >
55- {{ options?.length ? $t('No results found') : $t('No items here ') }}
55+ {{ $t('No results found') }}
5656 </div >
5757
5858 <div v-if =" $slots['extra-item']" class =" px-4 py-2 dark:text-gray-400" >
@@ -148,6 +148,10 @@ const props = defineProps({
148148 type: Boolean ,
149149 default: false ,
150150 },
151+ searchDebounceMs: {
152+ type: Number ,
153+ default: 300 ,
154+ },
151155});
152156
153157const emit = defineEmits ([' update:modelValue' , ' scroll-near-end' , ' search' ]);
@@ -165,14 +169,20 @@ const dropdownStyle = ref<{ top?: string; }>({
165169
166170const selectedItems: Ref <any []> = ref ([]);
167171const internalSelect = ref <HTMLElement | null >(null );
172+ let searchDebounceHandle: ReturnType <typeof setTimeout > | null = null ;
168173
169174function inputInput() {
170175 if (! props .multiple && selectedItems .value .length ) {
171176 selectedItems .value = [];
172177 emit (' update:modelValue' , null );
173178 }
174179 if (! props .searchDisabled ) {
175- emit (' search' , search .value );
180+ if (searchDebounceHandle ) {
181+ clearTimeout (searchDebounceHandle );
182+ }
183+ searchDebounceHandle = setTimeout (() => {
184+ emit (' search' , search .value );
185+ }, props .searchDebounceMs );
176186 }
177187}
178188
@@ -329,6 +339,10 @@ onUnmounted(() => {
329339 if (props .teleportToBody ) {
330340 window .removeEventListener (' scroll' , handleScroll , true );
331341 }
342+ if (searchDebounceHandle ) {
343+ clearTimeout (searchDebounceHandle );
344+ searchDebounceHandle = null ;
345+ }
332346});
333347
334348const getDropdownPosition = computed (() => {
0 commit comments