CuppaLabs / angular2-multiselect-dropdown

Angular 2 Dropdown Multiselect
https://cuppalabs.github.io/angular2-multiselect-dropdown
MIT License
293 stars 256 forks source link

List is not getting refresh after OnPush Change Detection with on Type API search #566

Open sachinmishra007 opened 3 years ago

sachinmishra007 commented 3 years ago

Hi,

I am using the angular multiselect drop-down. I am calling the API onSearch event on key press and marking api call with denounce of 500. And also my component has OnPush change Detection.

After resolving the data component does not show the latest data or refresh the data.

Regards Sachin

aimeeso commented 3 years ago

I also encounter a similar situation. I set lazyLoading to be true and refresh the data by ngOnChanges. Although the data is refreshed, the list is not showing the latest data. I am using Angular 11. I also noticed a weird thing. The list will be refreshed if I close the dropdown and open it again.

leopardy commented 3 years ago

Did this have a solution? I too am struggling with this. I am using primeng 12 angular 12 and am seeing the same behavior for BOTH p-dropdown and p-multiselect were they were working fine in every way, but as soon as I change to OnPush detection, I can no longer fill the multi-select with options and the dropdown does get filled(it's inside a p-table so maybe this has something to do to why it does get initially filled?) but will not allow me to select any option within it and it won't close once I open it. For both cases I am doing something like

this.myService
      .getDataFromBackend()
      .toPromise()
      .then(
          (result) => {
              this.myMultiselectOption = [...this.myMultiselectOptions, ...result.data]
              this.cd.detectChanges();
       });
P1N2O commented 3 years ago

Same here! Data refresh on version 4.x.x is perfect. I didn't find a solution too. If I downgrade to 4.x versions, I'm able to update dropdown data. But I get all the other older bugs that were present. 😢

aimeeso commented 3 years ago

I also encounter a similar situation. I set lazyLoading to be true and refresh the data by ngOnChanges. Although the data is refreshed, the list is not showing the latest data. I am using Angular 11. I also noticed a weird thing. The list will be refreshed if I close the dropdown and open it again.

I fixed the issue by setting this.dropdown.virtualScroollInit = true; when the dropdown is opened the first time.