Vue-select: Open programatically, and keep dropdown Open

Created on 4 May 2019  路  6Comments  路  Source: sagalbot/vue-select

So, i would like to implement a search select that open with a button, and the dropdown keeps open until closed not like the way it works right now that closes on input blur, something like what stripe does:

Image of Stripe's search select

The limitations right now with vue-select are, that there are no way to keep the drop down open and there's no way to open it programatically, my workaround for this is to do something like this:

<button @click="openSelect" class="btn">{{ label }}</button>

<v-select
      v-show="isOpen"
      ref="localeSearch"
      :options="normalizeOptions"
    >
    </v-select>

methods: {
    openSelect() {
      if (this.isOpen) {
        return this.$nextTick(() => this.$refs.localeSearch.searchEl.focus());
      }
      this.isOpen = !this.isOpen;
    }
  }

it works half ok, because, the moment i click, somewhere else, well, the dropdown disspaears, but the input keeps on sight, i can try and workaround this using the @search:blur event and setting isOpen = false but it seems hacky and doesn't work that well, because now the button gets in a loop of course

Check this Sandbox i prepare with that implementation

So to summarize:

  • A way to keep the dropwdown open, no matter if it's blur or not
  • A way to open show the select programatically
UX focus toggle

Most helpful comment

I'm struggling with the same issue. Nearly impossible to use Inspect in the browser dev tool as dropdown disappears on any click outside.

All 6 comments

I'm struggling with the same issue. Nearly impossible to use Inspect in the browser dev tool as dropdown disappears on any click outside.

Related #1067

A workaround in case you want to inspect the dom of the opened dropdown.
Open the node_modules/vue_select/dist/vue-select.js search for closeSearchOptions comment the contents of the function.
Restart your webpack (other build solutions).
Revert back when you are done.

I'm struggling with the same issue. Nearly impossible to use Inspect in the browser dev tool as dropdown disappears on any click outside.

Same problem. Did anyone find a workaround for this?

Check this out #758 (comment)

$vm0.isOpen=true worked for me 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manjunath-coachthem picture manjunath-coachthem  路  3Comments

rudykaze picture rudykaze  路  3Comments

NexoraSolutions picture NexoraSolutions  路  3Comments

pud1m picture pud1m  路  3Comments

gilles6 picture gilles6  路  3Comments