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

[DataGrid] Fix values labels in is any of filter operator #11939

Merged
merged 1 commit into from
Feb 19, 2024

Conversation

gitstart
Copy link
Contributor

@gitstart gitstart commented Feb 5, 2024

Description

SIngleSelect columns now displays label property instead of value property

Closes 11755

Refs

Loom Video


This code was written and reviewed by GitStart Community. Growing great engineers, one PR at a time.

@mui-bot
Copy link

mui-bot commented Feb 5, 2024

Deploy preview: https://deploy-preview-11939--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against 64423c2

@michelengelen michelengelen added component: data grid This is the name of the generic UI component, not the React module! feature: Filtering Related to the data grid Filtering feature labels Feb 6, 2024
@michelengelen michelengelen changed the title MUIX-11755 - [data grid] SingleSelect columns stopped getting the label correctly for "is any of" starting from 7.0.0-alpha.7 [data grid] SingleSelect columns stopped getting the label correctly for "is any of" starting from 7.0.0-alpha.7 Feb 6, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 7, 2024
Copy link

github-actions bot commented Feb 7, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 13, 2024
@gitstart gitstart marked this pull request as ready for review February 13, 2024 13:56
@gitstart
Copy link
Contributor Author

@cherniavskii This PR is ready for review

@michelengelen
Copy link
Member

@MBilalShafi adding you as reviewer since @cherniavskii is OOO

@michelengelen michelengelen requested review from MBilalShafi and removed request for cherniavskii February 15, 2024 09:54
Copy link
Member

@MBilalShafi MBilalShafi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, seems to work as expected now!

resolvedValueOptions?.find((resolvedValue) => getOptionValue(resolvedValue) === value),
)
.filter((value) => value !== undefined) as ValueOptions[];
}, [getOptionValue, item.value, resolvedValueOptions]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe do in one go?

diff --git a/packages/x-data-grid/src/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.tsx b/packages/x-data-grid/src/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.tsx
index 517860549..1d274b335 100644
--- a/packages/x-data-grid/src/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.tsx
+++ b/packages/x-data-grid/src/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.tsx
@@ -79,11 +79,15 @@ function GridFilterInputMultipleSingleSelect(props: GridFilterInputMultipleSingl
       return [];
     }
 
-    return item.value
-      ?.map((value) =>
-        resolvedValueOptions?.find((resolvedValue) => getOptionValue(resolvedValue) === value),
-      )
-      .filter((value) => value !== undefined) as ValueOptions[];
+    return item.value.reduce<ValueOptions[]>((acc, value) => {
+      const resolvedValue = resolvedValueOptions.find(
+        (v) => getOptionValue(v) === value,
+      );
+      if (resolvedValue != null) {
+        acc.push(resolvedValue);
+      }
+      return acc;
+    }, [] as ValueOptions[]);
   }, [getOptionValue, item.value, resolvedValueOptions]);
 
   const handleChange = React.useCallback<

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The adjustment has been made @MBilalShafi, thanks for the review.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 16, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Feb 16, 2024
Co-authored-by: jasmyneokudo <38866525+jasmyneokudo@users.noreply.github.com>
Co-authored-by: seunexplicit <48022904+seunexplicit@users.noreply.github.com>
@michelengelen michelengelen merged commit 007fc44 into mui:next Feb 19, 2024
17 checks passed
@michelengelen
Copy link
Member

Thanks @gitstart 🙇🏼

@cherniavskii cherniavskii changed the title [data grid] SingleSelect columns stopped getting the label correctly for "is any of" starting from 7.0.0-alpha.7 [DataGrid] Fix labels for value in is any of filter operator Feb 22, 2024
@cherniavskii cherniavskii changed the title [DataGrid] Fix labels for value in is any of filter operator [DataGrid] Fix values labels in is any of filter operator Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! feature: Filtering Related to the data grid Filtering feature
Projects
None yet
4 participants