-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[data grid] Boolean operator is
does not filter for false
value correctly
#14076
Comments
is
does not filter for false
value correctlyis
does not filter for false
value correctly
Hey @cravindra mui-x/packages/x-data-grid/src/colDef/gridBooleanOperators.ts Lines 9 to 11 in 7d86cfd
Here is a diff with a fix: diff --git a/packages/x-data-grid/src/colDef/gridBooleanOperators.ts b/packages/x-data-grid/src/colDef/gridBooleanOperators.ts
index 840019455..07f0f6b1f 100644
--- a/packages/x-data-grid/src/colDef/gridBooleanOperators.ts
+++ b/packages/x-data-grid/src/colDef/gridBooleanOperators.ts
@@ -6,7 +6,7 @@ export const getGridBooleanOperators = (): GridFilterOperator<any, boolean | nul
{
value: 'is',
getApplyFilterFn: (filterItem: GridFilterItem) => {
- if (!filterItem.value) {
+ if (filterItem.value === null || filterItem.value === undefined) {
return null;
} |
@michelengelen out of curiosity, what is the advantage of your code compared to the simpler: diff --git a/packages/x-data-grid/src/colDef/gridBooleanOperators.ts b/packages/x-data-grid/src/colDef/gridBooleanOperators.ts
index 840019455..07f0f6b1f 100644
--- a/packages/x-data-grid/src/colDef/gridBooleanOperators.ts
+++ b/packages/x-data-grid/src/colDef/gridBooleanOperators.ts
@@ -6,7 +6,7 @@ export const getGridBooleanOperators = (): GridFilterOperator<any, boolean | nul
{
value: 'is',
getApplyFilterFn: (filterItem: GridFilterItem) => {
- if (!filterItem.value) {
+ if (filterItem.value == null) {
return null;
} For me this is THE use case where double equality is superior to triple one |
This is a fundamental feature that is just fully broken since V7, it's majorly impacting us and is unfixed since August. Please take some time to look at this. Order ID: 95800 |
This is fixed in #15252 |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @cravindra How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
@cravindra Sry that we missed your PR with the fix completely. We can certainly do better than this. Next time make sure to tag me on your opened PR and I will handle adding reviewers and see it through! Again: Sry that this happened and I hope you understand that this can, but shouldn't, happen in a big codebase like this! 🙇🏼 |
Thanks, @michelengelen! I appreciate the acknowledgement - no hard feelings - I can barely keep up on my tiny codebases so I can completely understand this happening on large project like MUI Glad that this is fixed though which I guess is the important part :) |
Latest version
Steps to reproduce
Link to live example: https://codesandbox.io/s/wizardly-glitter-3234st?file=/src/Demo.tsx
Current behavior
All 4 items are displayed when trying to filter for
false
valuesExpected behavior
Only item 3 and 4 that have
isAdmin
set tofalse
should be shownContext
Set up:
With columns and rows:
and when the
filterModel
is set to:Expected behaviour
I'd expect only items 3 and 4 to be displayed
Actual behaviour
All rows are shown
RCA
This is implementation of the
is
operator forboolean
columns:Defined here: packages/x-data-grid/src/colDef/gridBooleanOperators.ts
When the value is
false
for a boolean field, the check ofif(!filterItem.value){...}
fails and we returnnull
that turns off filtering altogether.Workaround
My guess is that the default filter menu sets the
value
prop on the filter model as astring
:and can be used if we can control the
filterModel
(as can be done in the live working reproduction code)Your environment
npx @mui/envinfo
Browser info:
Search keywords: is, boolean, filter, data-grid, datagrid
The text was updated successfully, but these errors were encountered: