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

DataTable: Global filter resets column filters #6663

Closed
Matthew404-fail opened this issue May 24, 2024 · 3 comments · Fixed by #6974 or leoo1992/GeradorQRCode#85 · May be fixed by mtech-31-quemistry/quemistry_client_web#20
Closed
Assignees
Labels
Component: Documentation Issue or pull request is related to Documentation
Milestone

Comments

@Matthew404-fail
Copy link

Matthew404-fail commented May 24, 2024

Describe the bug

The global filter resets column filters.

Reproducer

https://stackblitz.com/edit/jyzjs8?file=src%2FApp.tsx

PrimeReact version

10.6.5

React version

18.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

  1. Go to reproducer
  2. Apply any column filter
  3. Enter any text in global filter field
  4. Column filter has been reset
  5. If you enter "Amy" in global filter field and then apply a column filter, it will work correctlyimage
    image
    image

Expected behavior

Filters will be applied together

@Matthew404-fail Matthew404-fail added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label May 24, 2024
@Et7f3
Copy link
Contributor

Et7f3 commented Aug 1, 2024

I can reproduce your error even with recent 10.8.0 version.
I think you just have too much code:
https://stackblitz.com/edit/vzt525-cyndyh?file=src%2FApp.jsx here it is a less buggy version: You can add column filter before global filter or the opposite and they will combine.
Try with o in global filter and "Bl" start with in name. You will see they merge correctly.

I said less buggy because when you erase global filter you get no filter (you need to reapply them) but this might be a desired behavior.

@melloware
Copy link
Member

@Et7f3 so is this not a bug?

Et7f3 added a commit to Et7f3/primereact that referenced this issue Aug 2, 2024
…olumn and global filter

Before the outerstate of DataTable was updated with the new global value and applied to column but local column state never bubbled to the outerstate and hence we loose information when global filter enter in action.
@Et7f3
Copy link
Contributor

Et7f3 commented Aug 2, 2024

@Matthew404-fail
your filter state is updated with your global handler and also by column event (when you click apply).

So in your reproducer I added line 431:

onFilter={(e) => setFilters(e.filters)}

and I wasn't able to reproduce the issue. You could also update with onFilterApplyClick on Column if you want to be more precise.

@melloware it is a documentation bug. The example given doesn't update the filter object. The reproducer was mostly taken for this example.

I proposed this PR #6974

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment