angular2-multiselect-dropdown icon indicating copy to clipboard operation
angular2-multiselect-dropdown copied to clipboard

Every Instance of Multiselect Dropdown calls onClose

Open wesley-wong opened this issue 7 years ago • 4 comments

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

wesley-wong avatar Sep 21 '18 00:09 wesley-wong

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.

maytanthegeek avatar Oct 10 '18 15:10 maytanthegeek

Also having this issue (v2.10.2). It's inside a NgbDropdown and even opening the dropdown fires the event.

ghost avatar Nov 15 '18 08:11 ghost

@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

dadreano avatar Dec 07 '18 23:12 dadreano

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)

sohaiebCollabCp avatar Mar 04 '22 11:03 sohaiebCollabCp