Skip to content

Commit

Permalink
[DataGridPro] Fix header filters rendering issue for isEmpty and `i…
Browse files Browse the repository at this point in the history
…sNotEmpty` filter operators (#14493)
  • Loading branch information
k-rajat19 committed Sep 17, 2024
1 parent 241bc51 commit 0d35d62
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import {
gridVisibleColumnFieldsSelector,
getDataGridUtilityClass,
useGridSelector,
GridFilterInputValue,
GridFilterInputDate,
GridFilterInputBoolean,
GridColType,
GridFilterInputSingleSelect,
gridFilterModelSelector,
gridFilterableColumnLookupSelector,
GridPinnedColumnPosition,
Expand Down Expand Up @@ -86,7 +91,16 @@ const useUtilityClasses = (ownerState: OwnerState) => {
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 {
Expand Down Expand Up @@ -147,7 +161,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) => {
Expand Down

0 comments on commit 0d35d62

Please sign in to comment.