-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[DataGridPro] Fix header filters rendering issue for isEmpty
and isNotEmpty
filter operators
#14493
Conversation
isEmpty
and isNotEmpty
filter operatorsisEmpty
and isNotEmpty
filter operators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for picking this up. 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having to update the behavior in the filter panel:
I'd rather keep the disabled input components in the header filter cell.
How about something like:
diff --git a/packages/x-data-grid-pro/src/components/headerFiltering/GridHeaderFilterCell.tsx b/packages/x-data-grid-pro/src/components/headerFiltering/GridHeaderFilterCell.tsx
index 1d22e8793..80ff6dfa2 100644
--- a/packages/x-data-grid-pro/src/components/headerFiltering/GridHeaderFilterCell.tsx
+++ b/packages/x-data-grid-pro/src/components/headerFiltering/GridHeaderFilterCell.tsx
@@ -18,6 +18,11 @@ import {
gridFilterModelSelector,
gridFilterableColumnLookupSelector,
GridPinnedColumnPosition,
+ GridFilterInputValue,
+ GridFilterInputDate,
+ GridFilterInputBoolean,
+ GridColType,
+ GridFilterInputSingleSelect,
} from '@mui/x-data-grid';
import {
GridStateColDef,
@@ -32,7 +37,6 @@ import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
import { DataGridProProcessedProps } from '../../models/dataGridProProps';
import { GridHeaderFilterMenuContainer } from './GridHeaderFilterMenuContainer';
import { GridHeaderFilterClearButton } from './GridHeaderFilterClearButton';
-
export interface GridRenderHeaderFilterProps extends GridHeaderFilterCellProps {
inputRef: React.RefObject<unknown>;
}
@@ -87,6 +91,19 @@ const dateSx = {
[`& input[value=""]:not(:focus)`]: { color: 'transparent' },
};
+const defaultInputComponents: {
+ [key in GridColType]: React.JSXElementConstructor<any> | null;
+} = {
+ string: GridFilterInputValue,
+ number: GridFilterInputValue,
+ date: GridFilterInputDate,
+ dateTime: GridFilterInputDate,
+ boolean: GridFilterInputBoolean,
+ singleSelect: GridFilterInputSingleSelect,
+ actions: null,
+ custom: null,
+};
+
const GridHeaderFilterCell = React.forwardRef<HTMLDivElement, GridHeaderFilterCellProps>(
(props, ref) => {
const {
@@ -147,7 +164,9 @@ const GridHeaderFilterCell = React.forwardRef<HTMLDivElement, GridHeaderFilterCe
);
const InputComponent =
- colDef.filterable || isFilterReadOnly ? currentOperator!.InputComponent : null;
+ colDef.filterable || isFilterReadOnly
+ ? (currentOperator.InputComponent ?? defaultInputComponents[colDef.type as GridColType])
+ : null;
const applyFilterChanges = React.useCallback(
(updatedItem: GridFilterItem) => {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shukriya for the review
this solution is much better than that I have proposed earlier
I missed checking that it is already working in v6
thanks again :)
isEmpty
and isNotEmpty
filter operatorsisEmpty
and isNotEmpty
filter operators
Hey @k-rajat19 Your changes seem to impact the commercially licensed code. For any changes of this nature, we require contributors to sign the MUI’s Contributor License Agreement (CLA). However, I can’t find a CLA signed that could cover these changes. Please follow the steps at https://mui-org.notion.site/CLA-Contributor-License-Agreement-92ece655b1584b10b00e4de9e67eedb0 to sign the document. |
I've sent the email to team-legal@mui.com |
@MBilalShafi, CLA signed, thanks. |
Deploy preview: https://deploy-preview-14493--material-ui-x.netlify.app/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…sNotEmpty` filter operators (mui#14493)
Fixes #14490