[ui.select:choices] Expected multiple .ui-select-choices-row but got '0'.

Error site found at code below

Created a silly workaround for this issue
setTimeout(function(){
var container = $element.querySelectorAll('.ui-select-choices');
for(var i = 0; i < 2; i++) {
var div = document.createElement('div');
div.className = 'ui-select-choices-row';
container[0].children[0].appendChild(div);
}
});
Thanks!
I had the same error. The bug occured in safari when using the mouse only and I did a little more debugging.
The problem I found was with the ng-if added to the choices itself: https://github.com/angular-ui/ui-select/blob/master/src/uiSelectChoicesDirective.js#L48
The ng-if seems to trigger after the _ensureHighlightVisible is called, which in turn lets the querySelector not find any elements (ng-if removed them from the DOM). After the error is triggered, the elements will be shown as usual, angular will still trigger the ng-if. Removing the .attr('ng-if', [...]) removed the bug. I do not know if there are any side effects with this, or if the performance impact is significant enough.
I'd like to have someone else test this, too
@lordnox Thanks for the workaround. I have been using Angular 1.5, and recently started getting the same error, as well as strange performance behavior, as if the browser was processing something and scroll was getting reset. I commented out the ng-if (added ; on line before as well).
choices.attr('ng-repeat', $select.parserResult.repeatExpression(groupByExp));
// .attr('ng-if', '$select.open'); //Prevent unnecessary watches when dropdown is close
Performance is back to normal and I do not see this error anymore. Thanks!
edit: I was also using an array of 100+ items, so perhaps an ng-if on each item was causing the lock up.
I had the same issue, @gatormike workaround worked for me as a temporary solution.
Me too, removing the .attr('ng-if', [...]) seems to work.
+1 @gatormike thx.
+1
Hey, guys, I have found how to fix this issue without Forking. I have added attribute(option) : tagging to the ui-select. This worked for me, peace!
Closing as a duplicate of #224
For my case the source of the bug was this:
if (ctrl.$animate && ctrl.$animate.on && ctrl.$animate.enabled(container[0])) {
ctrl.$animate.on('enter', container[0], function (elem, phase) {
if (phase === 'close') {
// Only focus input after the animation has finished
$timeout(function () {
ctrl.focusSearchInput(initSearchValue);
console.log('focusSearchInput()'); // Gets called hunreds of times
});
}
});
The ctrl.focusSearchInput(initSearchValue) gets called for too many times which will call the _ensureHighlightVisible(); accordingly.
Removing the ngAnimate module fixes the problem.
Add the tagging attribute binded to a function that return null, like this plunker, works for me too.
HTML:
<ui-select ... tagging="tagHandler" ... >
JS:
$scope.tagHandler = function (tag){
return null;
}
@lsanczyk Your solution works for me, thank you!
Angular 1.5.0 ui-select 0.14.3
Thanks @lsanczyk, your solutions saved my day!
Thanks @lsanczyk Your solution works for me, thank you! Very good