Skip to content
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

Cannot deselect items on Angular 9 + Ivy #111

Open
sonicfran86 opened this issue Nov 4, 2020 · 4 comments
Open

Cannot deselect items on Angular 9 + Ivy #111

sonicfran86 opened this issue Nov 4, 2020 · 4 comments

Comments

@sonicfran86
Copy link

Hi,

I'm using Angular 9 with Ivy enabled and ngx-drag-to-select 4.0.0.

When I select 2 or more items (either dragging or ctrl + click) I cannot deselect them anymore.
However, if I disable Ivy it works fine again

@d3lm
Copy link
Owner

d3lm commented Nov 4, 2020

Hey, thanks for reporting this issue. Please fork the StackBlitz, and re-create the issue. On the demo page, which has Ivy enabled, it works just fine. That said, the demo is using the latest version of Angular (10.x).

@d3lm
Copy link
Owner

d3lm commented Nov 4, 2020

CleanShot 2020-11-04 at 13 15 29

@sonicfran86
Copy link
Author

sonicfran86 commented Nov 4, 2020

thank you for your quick response @d3lm.

I was able to reply the issue in this fork: https://ngx-drag-to-select-2kmfrw.stackblitz.io

The problem happens when I add 2 nested *ngIf directives inside the items loop, while one is depending on selectedItems binding. This is the piece of html that I added:

<mat-card *ngFor="let document of documents" [dtsSelectItem]="document">
	{{ document.name }}
	<div *ngIf="selected.length > 1">
             <div *ngIf="true"></div>
        </div>
</mat-card>

@d3lm
Copy link
Owner

d3lm commented Nov 4, 2020

Yea ok, so in general, you don't wanna do this. The reason for this is an ngIf inside the select items change their bounding boxes. Generally this is not a big deal but requires you do manually update the bounding boxes in those cases. The library is not responsible for attaching resize listeners for each item, because that has quite some performance impact. Basically, while you're dragging, those conditional elements are shown / hidden and that changes their bounding boxes, and consequentially dragging breaks as well as toggling elements. Check the update() method on the select container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants