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

selectedItems still selected after clearing them via [x] Button

Open iProgramer opened this issue 6 years ago • 2 comments

When I selected some items and want to deselect them with the DeselectAll-Button [x], they get removed from the UI but they're still selected in the array. The only way to clear them correctly is, to deselect them one by one. Unfortunately the DeselectAll-Button can't be removed by the settings.

I have replicated the issue at https://stackblitz.com/edit/angular-yatsa4?file=src%2Fapp%2Fapp.component.html

My current workaround is to use the 'onDeSelectAll'-Event and clear the selectedItems manually by initializing a new array.

iProgramer avatar Sep 26 '19 06:09 iProgramer

This button DeselectAll-Button [x] calls onDeSelectAll() method

public onDeSelectAll(items: any) {
    console.log(items)
  }

In this method items will be empty [] so you can use this for update your array of selected items But this.selectedItems still with previous data but it is not problem for you

ps: I think it's not a bug, it wasn't problem to me

Tanyuta avatar Apr 11 '20 19:04 Tanyuta

just to clarify

public onDeSelectAll(items: any) {
    console.log(items)
}

in this example, the parameter items will always be empty/undefined, isn't it? So why use it at all? I can't imagine it's on purpose, that you have to manually update the array after the given DeselectAll-Button [x] gets clicked.

It's not a big problem, because a workaround exists. Just wanted to mention, that this behavious exists and I'm not sure if it's supposed to work like this. :-)

iProgramer avatar Apr 12 '20 09:04 iProgramer