d3lm / ngx-drag-to-select

A lightweight, fast, configurable and reactive drag-to-select component for Angular 10 and beyond
https://www.npmjs.com/package/ngx-drag-to-select
MIT License
293 stars 64 forks source link

SelectItemDirective.value unexpectedly returns this instead of dtsSelectItem when dtsSelectItem is falsy #160

Closed Eagleseb closed 2 years ago

Eagleseb commented 2 years ago

Minimal template to reproduce issue:

<dts-select-container
  (selectedItemsChange)="selectItems($event)"
>
    <div
      [dtsSelectItem]="0"
    >
</div
</dts-select-container>

Selecting div item will call selectItems method with array [SelectItemDirective] instead of [0]. Same thing for any dstSelectItem with falsy value. I think this is because internally, SelectItemDirective.value checks if dtsSelectItem is truthy. Instead it should check if dtsSelectItem !== undefined.

I can push a PR if you are interested.

Sorry if I'm not opening an issue correctly, first contribution here.

d3lm commented 2 years ago

Hey. Please provide a reproduction using stackblitz.com. I am pretty busy right now so I can't look into it and would appreciate a PR.

Eagleseb commented 2 years ago

Hello, thanks for your reply. Here's a fork of the project stackblitz putting the issue in evidence: https://stackblitz.com/edit/ngx-drag-to-select-7gyu4j?file=src/app/app.component.html

as you can see, with [dtsSelectItem]="document.id", selecting the document with id 0 (falsy) wrongly select the DTS directive instead of the id: image

I'll open a PR in a few days