Skip to content

Hide search box if select is empty#2828

Merged
kevin-brown merged 1 commit into
select2:masterfrom
ludomon:patch-3
Nov 25, 2014
Merged

Hide search box if select is empty#2828
kevin-brown merged 1 commit into
select2:masterfrom
ludomon:patch-3

Conversation

@ludomon

@ludomon ludomon commented Nov 25, 2014

Copy link
Copy Markdown

Fix #2822.
When a select box is empty (this appends in my case, I have a dynamic select box), the search box should not be shown.

Fix #2282.
When a select box is empty (this appends in my case, I have a dynamic select box), the search box should not be shown.
@kevin-brown

Copy link
Copy Markdown
Member

I think you have the wrong ticket number.

Can you also create a pair of jsfiddles that demonstrate the issues and the fix (using the changes here) so we can review this quicker?

@ludomon

ludomon commented Nov 25, 2014

Copy link
Copy Markdown
Author

I had indeed the wrong ticket numer, sorry...
You can see the fiddle : http://jsfiddle.net/DuNzR/1/

@kevin-brown

Copy link
Copy Markdown
Member

Unfortunately this doesn't appear to hide the search box for me.

I forked the jsfiddle and pulled in the code on this branch: http://jsfiddle.net/ydgne173/

image

Both fiddles give the same result under Chrome 39.

@ludomon

ludomon commented Nov 25, 2014

Copy link
Copy Markdown
Author

Thanks for your time.
I didn't commit on master, but on patch-3, so I updated your fiddle and it works : http://jsfiddle.net/ydgne173/1/

@kevin-brown

Copy link
Copy Markdown
Member

My bad, I completely missed that it wasn't pointing at the right branch. I've also created a jsfiddle that tests that the fix doesn't hide the search when there is text in the search field.

kevin-brown added a commit that referenced this pull request Nov 25, 2014
Hide search box if select is empty
@kevin-brown
kevin-brown merged commit 48ae56a into select2:master Nov 25, 2014
@franckl

franckl commented Apr 24, 2015

Copy link
Copy Markdown
Contributor

This commit is creating a "Uncaught TypeError: this.showSearch is not a function" when using the latest stable/3.5 branch.

See #1311 (same issue already fixed in the past)

@vevisystems

Copy link
Copy Markdown

I think this is an unfortunate change, because if createSearchChoice() is provided, the search box should be visible in order for the user to enter the desired text. What about changing:

this.showSearch(search.val());

with:

this.showSearch(search.val() || this.opts.createSearchChoice);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants