sagalbot / vue-select

Everything you wish the HTML <select> element could do, wrapped up into a lightweight, extensible Vue component.
https://vue-select.org
MIT License
4.63k stars 1.34k forks source link

Ajax Select sometimes stops and shows "no matches" just before showing the matches #1766

Closed iwasherefirst2 closed 1 year ago

iwasherefirst2 commented 1 year ago

Please respect maintainers time by filling in these sections. Your issue will likely be closed without this information.

Describe the bug I am using this package like this:

<template>
    <vSelect :options="options" class="bg-white" @search="searching" />
</template>

<script setup>
import vSelect from 'vue-select'
import "vue-select/dist/vue-select.css";
import axios from 'axios';

const options = ref([]);

function searching(search, loading) {
    loading(true);

    axios.post('/dashboard/users/search', {key: search.trim()})
        .then(response => {
            options.value = response.data;
        })
        .catch(error => {
            console.error(error);
        })
        .finally(() => {
            loading(false);
        });
}
</script>

<style scoped>
</style>

When I enter something in the input box, the following happens: 1.The loading spinning appears,

  1. The loading spinner stops
  2. For only 1ms it shows "Sorry, no matches found" and then
  3. All results are shown in the dropdown.

This happens only for some input, not for every.

Here is a screen recording of the issue: https://www.youtube.com/watch?v=jJ28R5jf5Nc

iwasherefirst2 commented 1 year ago

Issue was caused because I always return a limited result set, and while entering something multiple ajax calls where made and sometimes he didn't find result in intermediate option list. Fixed with :filterable="false", my bad