gfranko / jquery.selectBoxIt.js

A jQuery Select Box Plugin for Mobile, Tablet, and Desktop
http://www.selectboxit.com
MIT License
852 stars 301 forks source link

hideCurrent option doesn't work #392

Open nileLivingston opened 6 years ago

nileLivingston commented 6 years ago

Hello again!

Thanks for the great plugin. I've found an issue with version 3.8.2, specifically with the hideCurrent option. It doesn't work correctly on the official example, so I'm confident this isn't an artifact of my implementation.

I think I've found the culprit, starting on line 1563:

if(self.options.hideCurrent) {
    activeElem.hide().promise().done(function () {
        self.listItems.show();
    });
}

After activeElem is hidden, the Promise returns and all of the listItems (including activeElem) are shown. This renders the hideCurrent option inoperative.

One way to fix this issue is to simply compare each list item against activeElem, and only show the item if they are not equal.

if (self.options.hideCurrent) {
    activeElem.hide().promise().done(function () {
        self.listItems.each(function() {
            if (!$(this).is(activeElem)) {
                $(this).show();
            }
        });
    });
}

Hope this helps!

vishalp36 commented 5 years ago

+1

afourmeaux commented 4 years ago

Yep, still not working