Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Search box not shown to search when data is an empty array #1805

Open
cvNOliveira opened this issue Sep 13, 2016 · 6 comments · May be fixed by #2099
Open

Search box not shown to search when data is an empty array #1805

cvNOliveira opened this issue Sep 13, 2016 · 6 comments · May be fixed by #2099

Comments

@cvNOliveira
Copy link

cvNOliveira commented Sep 13, 2016

I have a ui-select that uses refresh to fetch data from server whenever a user inserts a char in input box (search box).
Since UI-Select v0.19.3 the input box is no longer available when data is an empty array, so the user cannot search to fetch data.
Needless to say that I only want to present data when the user search for it.

This only happens with theme "select2".
With boostrap theme it is ok.

Angular version: 1.5.5
UI-Select: 0.19.3

@user378230
Copy link
Contributor

Most likely caused by 4c561ac

@cvNOliveira If you made a plunkr as requested in the github issue template I could have tested in 2 minutes and reverted the commit and resolved this issue. But you didn't 😞

Can you test reverting the change in the above commit and see if it resolves your problem? If it does, I'll revert in master. Thanks! 👍

@cvNOliveira
Copy link
Author

You are right, my bad! I should have made the plunkr.
Anyways, I have managed to solve the problem excluding the theme from the condition on line 1388.
Probably not the best option, but it worked for me.

Old code:
if (!uisOffset(dropdown).height && $select.$animate && $select.$animate.on && select.$animate.enabled(dropdown))

New Code

var isSelect2Theme = angular.element(element).hasClass("select2");
if (!uisOffset(dropdown).height && $select.$animate && $select.$animate.on && $select.$animate.enabled(dropdown) && !isSelect2Theme)

I hope it helps.
Cheers!

@user378230
Copy link
Contributor

Did you try reverting 4c561ac? I thought that would have been the cause... maybe not then.

@cvNOliveira
Copy link
Author

I did not revert that commit because, as far as I can see, it has not to do with multiple choices and that commit is related with select-multiple template.

In this case, it's an opacity property that remains 0 because, for select2, at some point the animation procedure does not change the opacity to 1.
Since select2 does not have animation, I disabled the animation procedure for this theme as mentioned in my last comment.

@Sparksx
Copy link

Sparksx commented Jan 11, 2018

Same problème 2 year after...
I've made a pr with @cvNOliveira solution, please take a look

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@Sparksx @cvNOliveira @user378230 and others