vue-select icon indicating copy to clipboard operation
vue-select copied to clipboard

How to disable the "no-options" slot ?

Open gilles6 opened this issue 6 years ago • 6 comments

How to remove the no-options li field below which is displayed when the search input box is editable: <li class="no-options">Sorry, no matching options.</li>

gilles6 avatar Mar 31 '18 16:03 gilles6

You can use an empty slot, like so:

<v-select>
  <span slot="no-options"></span>
</v-select>

cirokd avatar May 16 '18 08:05 cirokd

@cirokd It looks awful. qwe Maybe there's another way...

Orange-Men avatar Jan 10 '19 15:01 Orange-Men

This will help only if you have something else to display, e.g. footer slot in my case.

But it can be removed with css by setting .vs__no-options to display none (and don't add the custom no-options slot). In case you were having trouble opening it with dev tools, here is the html.

<ul id="vs1__listbox" role="listbox" style class="vs__dropdown-menu>
  <li class="vs__no-options">Sorry, no matching options.</li>
</ul>

n-smits avatar Apr 24 '20 00:04 n-smits

I am actually experiencing the same issue now. What I did is like this:

<v-select :data-hide-options="!searchKey && !options.length" ../>

And then via CSS:

[data-hide-options='true'] ul[role='listbox'] {
    display: none !important;
}

This works for me! (at least for the meantime)

erwinmesi avatar Aug 09 '21 08:08 erwinmesi

How to show no-options slot only when you actually search something:

<v-select
    ref="select"
    @search="onSearch"
    @open="onOpen"
>
    <template #no-options>Nothing found</template>
</v-select>

and methods:

async onSearch (search, loading) {
  if (!search.length) {
    this.$refs.select.open = false
    return
  }

  this.$refs.select.open = true
  this.isSearching = true
  loading(true)

  // ajax query...

  loading(false)
  this.isSearching = false
},
onOpen () {
  if (!this.options.length && !this.isSearching) {
    this.$refs.select.open = false
  }
}

waleev avatar Nov 10 '21 05:11 waleev

@sagalbot , first of all, thank you for your work!

maybe there is some update about this request?

SokolovskyAlex avatar Sep 15 '22 08:09 SokolovskyAlex