primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Multiselect on chips display does not update the model when deleting them from the chip icon

Open gxenakis opened this issue 6 years ago • 6 comments

I'm submitting a [X] bug report

Current behavior On chips display when you delete a chip by clicking the X button the model doesn't refresh

Expected behavior Model should be refreshed like when you unclick from the dropdown list.

Minimal reproduction of the problem with instructions https://primeng-multiselect-demo.stackblitz.io/

gxenakis avatar Nov 26 '20 10:11 gxenakis

Also discovered this when I was implementing it. Tried both using the formControlName inside of a reactive form as well as just binding with NgModel. Neither updated the model when removing items using the x inside of the chip

tvbowersz avatar Dec 05 '20 15:12 tvbowersz

Here is a question at StackOverflow and here is my workaround, Actually, what is missing is this.onModelChange(this.value); call at removeChip() function

andriy101 avatar Dec 06 '20 00:12 andriy101

Besides from that the onChange event is not called/emitted when removing a chip. I don't know if I should open another issue for this or if it fits in here.

Timmeeeey avatar Dec 07 '20 07:12 Timmeeeey

No need to open a new issue, my pull request fixes this current issue for both template druiven and reactive forms

andriy101 avatar Dec 07 '20 07:12 andriy101

@andriy101 this.onModelChange(this.value); is not emitting onChange. It is only emitted by onOptionClick(event) and toggleAll(event).

Timmeeeey avatar Dec 07 '20 08:12 Timmeeeey

@andriy101 this.onModelChange(this.value); is not emitting onChange. It is only emitted by onOptionClick(event) and toggleAll(event).

I added onChange emit with new value and the mouse event passed from the template via (click) function.

andriy101 avatar Dec 08 '20 00:12 andriy101