lordfriend / nya-bootstrap-select

An AngularJS select replacement which build select like dropdown component with collection and ng-model support
http://nya.io/nya-bootstrap-select/
MIT License
179 stars 81 forks source link

Change live-search from String to Expression #135

Closed matt328 closed 8 years ago

matt328 commented 8 years ago

I'm working with a bunch of dynamically populated drop downs, changing one could cause the options of another to change. It would be nice to only show the search if there were enough options to warrant it.

At a quick glance of the code it doesn't look like changing liveSearch to be an expression instead of a string would be too difficult: add a watch on the expression, and add and remove the searchbox from the markup. Or possibly hide and show, I recall reading some gotcha about modifying the dom in directives.

Do you see any show stoppers to doing this? Would you be interested in a PR if I manage to not screw it up too bad?

lordfriend commented 8 years ago

live-search tangled with too many listeners and logic, SO it is very hard to switch on and off base an expression value. I put the DOM manipulation for live-search in compile function also make it impossible to dynamically change the behavior.

matt328 commented 8 years ago

Would there be any issues with adding an expression to just change the visibility of the search box via CSS?

lordfriend commented 8 years ago

There are many related operations when enabling live-search, I know this is a design flaw, But currently big change is not very acceptable because I don't have much time on this.

https://github.com/lordfriend/nya-bootstrap-select/blob/master/src/nya-bs-select.js#L351-L358

https://github.com/lordfriend/nya-bootstrap-select/blob/master/src/nya-bs-select.js#L490-L494

lordfriend commented 8 years ago

A workaround is that you can use ng-if to toggle two select with same settings except the live-search

matt328 commented 8 years ago

That sounds like what I will need to do in the meantime. I don't have much time either, but maybe at some point I can try to fix the design flaw and submit a PR.