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: Advance Filtering Issue with multiple negation #7542

Closed
the-pratik opened this issue Jan 2, 2025 · 8 comments
Closed

DataTable: Advance Filtering Issue with multiple negation #7542

the-pratik opened this issue Jan 2, 2025 · 8 comments
Labels
Resolution: Wontfix Issue will not be fixed due to technical limitations

Comments

@the-pratik
Copy link

Describe the bug

Issue Summary

When using the match any filter mode on the PrimeReact DataTable, applying multiple filters with not equals or not contains conditions returns rows that should have been excluded based on the filter criteria.

Steps to Reproduce

Use the PrimeReact DataTable with a dataset (example: a column named "Country").
Apply the following filters in match any mode:
Condition 1: Not equals "Egypt"
Condition 2: Not contains "lovenia"
(or any combination of not equals and not contains filters).
Observe the results: rows that should have been excluded by the applied filters are still displayed.

Expected Behavior

Rows meeting any of the not equals or not contains conditions should be excluded when using the match any filter mode.

Actual Behavior

The DataTable still displays rows that match the conditions specified in the not equals and not contains filters.

Screenshot

Here’s an example where:

Condition 1: Not equals "Egypt"
Condition 2: Not contains "lovenia"

AdvanceNotFilters

Same goes with the negation filter for date with match mode 'Any' ->

image

Additional Notes

This issue might be due to an incorrect implementation of the match any filter logic when combining not equals and not contains filters.
The same applies for all datatypes in JavaScript.

Would appreciate a fix or a workaround for this issue. Let me know if more details are needed.

Reproducer

https://stackblitz.com/edit/vitejs-vite-y5nolsku?file=src%2FAdvancedDataTable.jsx

System Information

System: 
  OS: Windows 11 10.0.22621 
  CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1145G7 @ 2.60GHz 
  Memory: 3.78 GB / 15.69 GB 

Binaries: 
  Node: 14.17.5 - C:\Program Files\nodejs\node.EXE 
  npm: 6.14.14 - C:\Program Files\nodejs\npm.CMD 

Browsers: 
  Edge: Chromium (130.0.2849.80) 
  Internet Explorer: 11.0.22621.3527 

npmPackages: 
  primereact: ^10.6.6 => 10.6.6 
  react: ^18.3.1 => 18.3.1

Steps to reproduce the behavior

Steps to Reproduce

Use the PrimeReact DataTable with a dataset (example: a column named "Country").
Apply the following filters in match any mode:
Condition 1: Not equals "Egypt"
Condition 2: Not contains "lovenia"
(or any combination of not equals and not contains filters).
Observe the results: rows that should have been excluded by the applied filters are still displayed.

Expected behavior

Expected Behavior

Rows meeting any of the not equals or not contains conditions should be excluded when using the match any filter mode.

Actual Behavior

The DataTable still displays rows that match the conditions specified in the not equals and not contains filters.

@the-pratik the-pratik added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jan 2, 2025
@melloware melloware added Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Jan 2, 2025
@melloware
Copy link
Member

@the-pratik you misunderstand "Match Any" Vs "Match All". It may seems a little confusing but...

Match Any says "Not Equal Egypt" AND "Not Contains lovenia" So that means every single row is true because Egypt does not contain Ioevnia.

Match All says "Not Equal Egypt" OR "Not Contains lovenia"

@the-pratik
Copy link
Author

@melloware But don't you think it contradicts their standard behavior:

"Match Any" typically implies an OR condition (rows match if any rule is true).

"Match All" typically implies an AND condition (rows match only if all rules are true).

@the-pratik
Copy link
Author

@melloware And if you try with non negative filters e.g. starts with a Match All ends with a
it filters with AND and if we use Match Any it uses OR.

Please refer to the attached screenshots:

Screenshot_20250102_182405_Chrome.jpg

Screenshot_20250102_182358_Chrome.jpg

The problem only occurs when we have negation filters like not contains, not equals they return true if it does not contains/not equals which results in adding the row into the dataset, whereas it should return false in case of negation filters so it doesn't get into the dataset.

Correct me if I'm wrong. I'll have a look at the code as well to see if I'm getting it correctly. Meanwhile I request you not to close the issue!

Thanks!

@melloware
Copy link
Member

Yep feel free to research I believe all PrimeTek libs uses the exact same pattern. But yes feel free to debug the code and report your results.

@melloware
Copy link
Member

It probably is related to having multiple "negation" filters

@the-pratik
Copy link
Author

It probably is related to having multiple "negation" filters

Yes it is, there is no problem for a single rule only occurs when we have 2 rules and negation filters.

@melloware melloware changed the title DataTable (React Table Component): Advance Filtering Issue DataTable: Advance Filtering Issue Jan 6, 2025
@melloware melloware changed the title DataTable: Advance Filtering Issue DataTable: Advance Filtering Issue with multiple negation Jan 6, 2025
@melloware
Copy link
Member

@the-pratik were you able to debug? If not I am going to close as my original analysis of saying "two things are not something" means one of them IS something.

@melloware melloware added Resolution: Wontfix Issue will not be fixed due to technical limitations and removed Resolution: By Design The behavior in the issue is by design and the component exhibits the expected behavior labels Jan 6, 2025
@the-pratik
Copy link
Author

@the-pratik were you able to debug? If not I am going to close as my original analysis of saying "two things are not something" means one of them IS something.

Hi @melloware , didn't get the chance to check the code you may close it. If I get something then I will check again.

@melloware melloware closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Wontfix Issue will not be fixed due to technical limitations
Projects
None yet
Development

No branches or pull requests

2 participants