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

Filter piping on the list #1063

Open
thethakuri opened this issue Aug 3, 2022 · 1 comment
Open

Filter piping on the list #1063

thethakuri opened this issue Aug 3, 2022 · 1 comment

Comments

@thethakuri
Copy link

thethakuri commented Aug 3, 2022

REQUIRED: Before filing a bug report

Change each [ ] to [x] when you have done it.

Describe the bug (required)

I have created a search filter pipe that filters the list of items in the container. Once I filter and drag and drop the item, looks like the actualy index of the item doesn't change. For e.g. if the list contains ['foo','bar'] and I filter for 'bar' and drag and drop, I get 'foo'. So it seems the index of the current item (e.g. 0) is still reference to the unfiltered list ['foo','bar'].

To Reproduce (required)

Steps to reproduce the behavior:

  1. Create a simple search filter such as:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
  name: 'searchFilter'
})
export class SearchFilterPipe implements PipeTransform {

  transform(value: any, args?: any): any {
    if(!value) return null;
    if(!args) return value;

    args = args.toLowerCase();

    return value.filter(function(data: any){
      return JSON.stringify(data).toLowerCase().includes(args);
    });
  }
}
  1. Apply it to the DOM element like this
<div id="group-source" [dragula]="'GROUPS_CONTAINER'" [(dragulaModel)]="group_names">
    <span *ngFor="let group_name of group_names | searchFilter: query">{{group_name}}</span>
</div>
  1. Filter list
  2. See error

Screenshots (optional)

If applicable, add screenshots to help explain your problem.

Versions (required)

Please state which versions of the following packages you have installed:
"ng2-dragula": "^2.1.1"

@thethakuri
Copy link
Author

I've worked around this by aplying a class that essentially changes the style to display:none

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

1 participant