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

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

Open cvNOliveira opened this issue 9 years ago • 6 comments
trafficstars

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

cvNOliveira avatar Sep 13 '16 13:09 cvNOliveira

Most likely caused by https://github.com/angular-ui/ui-select/commit/4c561ac9aa9dd7960b1285952a5d64b5538777b3

@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 :disappointed:

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! :+1:

user378230 avatar Sep 16 '16 10:09 user378230

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!

cvNOliveira avatar Sep 16 '16 15:09 cvNOliveira

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

user378230 avatar Sep 16 '16 17:09 user378230

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.

cvNOliveira avatar Sep 17 '16 11:09 cvNOliveira

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

Sparksx avatar Jan 11 '18 13:01 Sparksx