Skip to content

Option to hide the dropdown when query is empty #1020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jods4 opened this issue Mar 10, 2016 · 9 comments
Open

Option to hide the dropdown when query is empty #1020

jods4 opened this issue Mar 10, 2016 · 9 comments
Labels
enhancement input component pending review This issue was closed as stale; since then additional review has been requested.

Comments

@jods4
Copy link

jods4 commented Mar 10, 2016

When the user backspaces and empties its query text, Selectize displays all the list of all available options.

(1) Sometimes this doesn't feel like a good UX, especially for AJAX autocompletes.

(2) Especially in the case of AJAX autocompletes, Selectize cache may have grown huge and sorting + displaying all options is slowing down the browser to a crawl.

@jfishbein
Copy link

+1 for this. Might try to tackle it when I get a chance.

@m272cels
Copy link

@jods4 I thought the same, this is my current workaround:

  $("#selectize").selectize({
    onDropdownOpen: function ($dropdown) {
      // Manually prevent dropdown from opening when there is no search term
      if (!this.lastQuery.length) {
        this.close();
      }
    }
  })

@jfishbein
Copy link

Thanks for this! I also had to add the following so the dropdown doesn't appear when you backspace out all that was previously typed:

onType: function (str) {
    if (str === "") {
        this.close();
    }
}

@joallard
Copy link
Member

joallard commented Apr 1, 2016

That boils down to "Do I want there be suggestions when the field is empty?", which I would accept a new option for.

@maslade
Copy link

maslade commented Mar 29, 2017

@m272cels's suggestion gave me problems when configured with maxItems: 1. Using Firefox 51 and selectize.js 0.12.4, that onDropdown handler is triggering an infinite loop and crashing the tab. With maxItems > 1, it worked fine.

I worked around it by changing it to the following (in addition to @jfishbein's snippet):

onDropdownOpen: function ( \$dropdown ) {
    \$dropdown.css( 'visibility', this.lastQuery.length ? 'visible' : 'hidden' );
}

@ghost
Copy link

ghost commented Jun 14, 2017

+1 for this

@parak80
Copy link

parak80 commented Oct 31, 2019

Hi, how can I do this in angular 7 anyone knows?
I have buttons and a menu as called kebabMenu and I want to priorotize buttons in a way that when the page become responsive the rest of the buttons go under the dropdown. I managed to do that by css query but when the dropdown is empty it also shows and its empty query. I wonder if someone can help me to check when there is no data in dropdown then hide it.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2021

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

@jods4
Copy link
Author

jods4 commented Jan 7, 2021

Don't close this, it's stale because everything about this feature has been said and it's waiting an implementation.

@risadams risadams added pending review This issue was closed as stale; since then additional review has been requested. and removed no-issue-activity labels Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement input component pending review This issue was closed as stale; since then additional review has been requested.
Projects
None yet
Development

No branches or pull requests

7 participants