-
-
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
[data grid] Incorrect class name rendered to GridToolbarQuickFilter when customized with GridToolbarContainer #12400
Comments
Hi @EvgenyWaveBL ... thanks for raising this issue. Since this is a relatively small fix I will add the diff --git a/packages/x-data-grid/src/components/toolbar/GridToolbarQuickFilter.tsx b/packages/x-data-grid/src/components/toolbar/GridToolbarQuickFilter.tsx
index a5ceb6edc..6758d62fb 100644
--- a/packages/x-data-grid/src/components/toolbar/GridToolbarQuickFilter.tsx
+++ b/packages/x-data-grid/src/components/toolbar/GridToolbarQuickFilter.tsx
@@ -3,6 +3,9 @@ import PropTypes from 'prop-types';
import TextField, { TextFieldProps } from '@mui/material/TextField';
import { styled } from '@mui/material/styles';
import { unstable_debounce as debounce } from '@mui/utils';
+import generateUtilityClass from '@mui/utils/generateUtilityClass';
+import composeClasses from '@mui/utils/composeClasses';
+import { getDataGridUtilityClass } from '@mui/x-data-grid/constants';
import { useGridApiContext } from '../../hooks/utils/useGridApiContext';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
import { useGridSelector } from '../../hooks/utils/useGridSelector';
@@ -71,9 +74,20 @@ export type GridToolbarQuickFilterProps = TextFieldProps & {
debounceMs?: number;
};
+const useUtilityClasses = (ownerState: OwnerState) => {
+ const { classes } = ownerState;
+
+ const slots = {
+ root: ['toolbarQuickFilter'],
+ };
+
+ return composeClasses(slots, getDataGridUtilityClass, classes);
+};
+
function GridToolbarQuickFilter(props: GridToolbarQuickFilterProps) {
const apiRef = useGridApiContext();
const rootProps = useGridRootProps();
+ const classes = useUtilityClasses(rootProps);
const quickFilterValues = useGridSelector(apiRef, gridQuickFilterValuesSelector);
const {
@@ -141,6 +155,7 @@ function GridToolbarQuickFilter(props: GridToolbarQuickFilterProps) {
placeholder={apiRef.current.getLocaleText('toolbarQuickFilterPlaceholder')}
aria-label={apiRef.current.getLocaleText('toolbarQuickFilterLabel')}
type="search"
+ className={classes.root}
{...other}
InputProps={{
startAdornment: <rootProps.slots.quickFilterIcon fontSize="small" />, Thanks again for raising this issue! 🙇🏼 |
Thanks buckets @michelengelen ! |
When creating a custom toolbar in DataGrid with GridToolbarQuickFilter, GridToolbarQuickFilter would not have MuiDataGrid-toolbarQuickFilter rendered as expected. Fixes mui#12400
How did we do @EvgenyWaveBL? |
Steps to reproduce
Link to live example
Current behavior
MuiFormControl rendered with class like: css-3be3ve-MuiFormControl-root-MuiTextField-root-MuiDataGrid-toolbarQuickFilter
Expected behavior
MuiFormControl rendered with class like: css-3be3ve-MuiFormControl-root MuiTextField-root MuiDataGrid-toolbarQuickFilter
Context
I am trying to write override styling using themeOptions, themeAugmentation and MuiDataGrid styleOverrides
Your environment
No response
Search keywords: QuickFilter, GridToolbar
The text was updated successfully, but these errors were encountered: