-
-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In multiselect, (selectionChange) event of the control does not contain all the elements but just the newly selected #387
Comments
@angelaki sorry for the issue so the FormControl has the correct set of selexted values but (selectionChange) does not emit the correct set? |
@macjohnny yes, correct! Tbh this wasn't even an intended behavior of my initial implementation but modifying the original source passed the correct event value. Now the form is correct but the event broken. |
Hmm i wonder why, because in
Any suggestion how to fix that? |
Let me check these days. Maybe you can somehow stop the even from propagation and only call the last one.
Grüße
Tristan Sprößer
…________________________________
From: Esteban Gehring ***@***.***>
Sent: Thursday, July 14, 2022 6:49:05 PM
To: bithost-gmbh/ngx-mat-select-search ***@***.***>
Cc: Tristan Sprößer ***@***.***>; Mention ***@***.***>
Subject: Re: [bithost-gmbh/ngx-mat-select-search] Hey, this fix just broke my behavior! By modifying a copy of values but not the original one the `(selectionChange)` event of the control does not contain all the elements but just the newly selected. (Issue #387)
Hmm i wonder why, because in https://github.com/bithost-gmbh/ngx-mat-select-search/blob/092aaf963d2b9cb3cb36f79cab1f6d3c6f35aa63/src/app/mat-select-search/mat-select-search.component.ts#L632 we set the correct values, but maybe because those options are not present while filtering, they get deselected (which is exactly the purpose of this workaround method, which to compensate for that)
Any suggestion how to fix that?
—
Reply to this email directly, view it on GitHub<#387 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AJGSUBKBTFDLNM7XQSGAE2TVUBAIDANCNFSM53SZ7G2A>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
(selectionChange)
event of the control does not contain all the elements but just the newly selected.
Ok, wow. Let's say: it's getting complicated. I made a fork to show the current misbehavior: https://github.com/angelaki/ngx-mat-select-search?organization=angelaki&organization=angelaki. The earlier version wasn't perfect at all, because the handler just manipulates the event value. It was more luck that it was the first handler called - but it somehow always is? I already tried toggling he search with *ngIf. The controls internal handler always seams to be called first. Lucky me ... Never the less, we are already in the |
Hey guys, I'm sorry to hear about the negative side effect of the fix. The initial error occurred when you have one or more selected, then you search for another value where the previous selected values are not part of the options anymore. When you select now the value, the previous selected values get unselected. I hope this helps. |
Ok so for the time being, I suggest we revert #377 and then analyze the situation of the readonly array |
Yeah, think so,too. @qstiegler can you create a minimal reproduction of your behavior? Your description sounds like this should always happen. This just isn't the case, as you can see in the live examples: https://stackblitz.com/github/bithost-gmbh/ngx-mat-select-search-example?file=src%2Fapp%2Fapp.component.html |
@angelaki Puh...it took me a while today to create a working minimal reproduction but now I figured it out. The problem is the combination with the Here is the link to reproduce: https://stackblitz.com/edit/angular-ivy-5dffxg
I think in general if you do manipulations of the form value object, it always should be immutable, that's why I thought my solution would be good. I hope we find another one which fixes both. As a short term solution I can create a copy of the array before I send it to the store but this is pretty prone to failure. I hope this will help you guys! |
Is there a reason why you closed it? I really hope you'll come up with an immutable solution. |
I'll create a unit test these days, check your sample and see what we / I can do. But tbh I think it'll be quite hard.
Grüße
Tristan Sprößer
…________________________________
From: Quirin Stiegler ***@***.***>
Sent: Tuesday, July 19, 2022 8:26:33 AM
To: bithost-gmbh/ngx-mat-select-search ***@***.***>
Cc: Tristan Sprößer ***@***.***>; Mention ***@***.***>
Subject: Re: [bithost-gmbh/ngx-mat-select-search] In multiselect, (selectionChange) event of the control does not contain all the elements but just the newly selected (Issue #387)
Is there a reason why you closed it? I really hope you'll come up with an immutable solution.
—
Reply to this email directly, view it on GitHub<#387 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AJGSUBJKEP2HRF6XK46KDGTVUZDBTANCNFSM53SZ7G2A>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@qstiegler I reopened #376 |
@angelaki this was released in 4.2.1 |
Hey, this fix just broke my behavior! By modifying a copy of values but not the original one the
(selectionChange)
event of the control does not contain all the elements but just the newly selected.@qstiegler Can you show me your usecase where version 4.1.1 threw an exception for you so I can maybe fix this?
Originally posted by @angelaki in #376 (comment)
The text was updated successfully, but these errors were encountered: