-
-
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] Header filters do not clear properly when losing focus #15778
Comments
Hey @TheOneTheOnlyJJ ... this is due to a faulty condition in the GridHeaderFilterCell component. This diff fixes it, but is likely not ideal. --- a/packages/x-data-grid-pro/src/components/headerFiltering/GridHeaderFilterCell.tsx
+++ b/packages/x-data-grid-pro/src/components/headerFiltering/GridHeaderFilterCell.tsx
@@ -314,7 +314,8 @@ const GridHeaderFilterCell = React.forwardRef<HTMLDivElement, GridHeaderFilterCe
const isNoInputOperator = currentOperator.requiresFilterValue === false;
- const isApplied = item?.value !== undefined || isNoInputOperator;
+ const isApplied = item?.value != null || isNoInputOperator;
+ const isEmpty = item?.value === '';
const label =
currentOperator.headerLabel ??
@@ -367,7 +368,7 @@ const GridHeaderFilterCell = React.forwardRef<HTMLDivElement, GridHeaderFilterCe
placeholder=""
isFilterActive={isFilterActive}
clearButton={
- showClearIcon && isApplied ? (
+ showClearIcon && !isEmpty && isApplied ? (
<GridHeaderFilterClearButton
onClick={clearFilterItem}
disabled={isFilterReadOnly} I'll add it to the board! 👍🏼 |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @TheOneTheOnlyJJ 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. |
Steps to reproduce
Steps:
Current behavior
I snipped this image from the MUI X Data Grid Demo linked above. The "X" icon button is rendered above the input field label.
If you follow the steps above, the result is visible.
Expected behavior
I expect the "X" icon button to either not show when the input value is empty, or at least get hidden when the input field loses focus. or to be
Context
I was playing around with the demos and noticed this issue.
Your environment
Chrome browser, Windows 10 machine.
Search keywords: data grid header filter losing focus click away
The text was updated successfully, but these errors were encountered: