Every Instance of Multiselect Dropdown calls onClose
I have a several multiselect dropdowns I'm using to filter results in a table.
I want to use the (onClose) event to start the filter method. It calls the onClose event as many times as I have multiselect dropdowns.
In addition, when inserting into the dom (using *ngif expression), the (onClose) event also fires for every instance
Same is happening with me. Just saw this and I have a feeling its not going to be resolved soon. onClose fires wherever I click on the component.
Also having this issue (v2.10.2). It's inside a NgbDropdown and even opening the dropdown fires the event.
@CuppaLabs I have same issue. The closeDropdown method is being called whenever you click outside the dropdown. If the dropdown is already closed, this is causing the onClose to still get fired. Angular: 6.2.2 Multiselect: 4.1.1
I have made a change that works on my local. I do not have access to make changes/branches for this repository so please make this change. https://github.com/dadreano/angular2-multiselect-dropdown/commit/78014fa4569ad8c679b45b061c1d5fbf1bc72436
Basing on @dadreano suggestion, i fixed this problem by overriding the component prototype method with this :
AngularMultiSelect.prototype.closeDropdown = function() {
if (this.searchInput && this.settings.lazyLoading) {
this.searchInput.nativeElement.value = "";
}
if (this.searchInput) {
this.searchInput.nativeElement.value = "";
}
this.filter = "";
if (this.isActive) {
this.isActive = false;
// this.searchTerm$.next(''); this line is specific for some versions not all
this.onClose.emit(false);
}
}
PS important: to apply this solution in all components, you have to implement it in the highest component level (like app.component.html in its constructor for example)