isteven / angular-multi-select

A multi select dropdown directive for AngularJS. Allows you to use HTML tags and CSS in the data. Requires only AngularJS and nothing else.
isteven.github.io/angular-multi-select
MIT License
1.08k stars 518 forks source link

Function assigned to on-search-change attribute doesn't get triggered when the labelFilter length changes from 1 to 0 #479

Closed Pranava29 closed 7 years ago

Pranava29 commented 8 years ago

This is causing so many issues in our code as the search change calls few other functions and in the above case it does not.

Fix: change the $scope.inputLabel.labelFilter.length > vMinSearchLength comparison to $scope.inputLabel.labelFilter.length >= vMinSearchLength

// Callback: on filter change
if ( $scope.inputLabel.labelFilter.length > vMinSearchLength ) { var filterObj = []; angular.forEach( $scope.filteredModel, function( value, key ) { if ( typeof value !== 'undefined' ) {
if ( typeof value[ attrs.groupProperty ] === 'undefined' ) {
var tempObj = angular.copy( value ); var index = filterObj.push( tempObj );
delete filterObj[ index - 1 ][ $scope.indexProperty ]; delete filterObj[ index - 1 ][ $scope.spacingProperty ];
} } }); $scope.onSearchChange({ data: { keyword: $scope.inputLabel.labelFilter, result: filterObj } }); }

Pranava29 commented 8 years ago

I have forked the branch and committed my changes https://github.com/Pranava29/angular-multi-select