mui-x icon indicating copy to clipboard operation
mui-x copied to clipboard

[data grid] `DataGridFilterPanel` responsiveness

Open Nitzperetz opened this issue 1 year ago • 8 comments

The problem in depth

Hey there, I am using DataGrid Filter Panel and would like to have some customizations if possible:

  1. Change Grid settings for filter panel - so in low resolutions instead of

image

I would expect to have responsive view: image

  1. Delete icon - Change icon
  2. Delete Button - move to the end of the line

Your environment

`npx @mui/envinfo`
 System:
    OS: macOS 14.3.1
  Binaries:
    Node: 20.6.1 - /opt/homebrew/bin/node
    npm: 9.9.2 
    pnpm: 8.6.2 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 122.0.6261.129
    Edge: 122.0.2365.80
    Safari: 17.3.1
  npmPackages:
    @emotion/react: 11.11.4 => 11.11.4
    @emotion/styled: 11.11.0 => 11.11.0
    @mui/base:  5.0.0-beta.17
    @mui/core-downloads-tracker:  5.14.11
    @mui/icons-material: 5.14.11 => 5.14.11
    @mui/lab: 5.0.0-alpha.146 => 5.0.0-alpha.146
    @mui/material: 5.14.11 => 5.14.11
    @mui/private-theming:  5.14.11
    @mui/styled-engine:  5.14.11
    @mui/system: 5.14.11 => 5.14.11
    @mui/types: 7.2.4 => 7.2.4
    @mui/utils:  5.15.7
    @mui/x-data-grid: 6.19.3 => 6.19.3
    @mui/x-data-grid-pro: 6.19.3 => 6.19.3
    @mui/x-license-pro: 6.10.2 => 6.10.2
    @mui/x-tree-view:  6.0.0-alpha.1
    @types/react: 18.2.18 => 18.2.18
    react: 18.2.0 => 18.2.0
    react-dom: 18.2.0 => 18.2.0
    typescript: 4.9.5 => 4.9.5

Search keywords: DataGridFilterPanel, FilterPanel, filterFormProps Order ID: 68140

Nitzperetz avatar Mar 14 '24 13:03 Nitzperetz

Hey @Nitzperetz, thanks for raising this issue. I agree that we could do a bit better. I did add this to our board for the team to discuss and estimate. Thanks again! 🙇🏼

michelengelen avatar Mar 14 '24 14:03 michelengelen

Thank you! I appreciate the quick response!

Nitzperetz avatar Mar 14 '24 14:03 Nitzperetz

@michelengelen is there anyway to get time estimations for the fixes? Thank you!

Nitzperetz avatar Mar 25 '24 15:03 Nitzperetz

@michelengelen I don't know if this is appropriate but I would like to add on the request to make the filter panel in column menu to be responsive like the above example as well.

image

Here2Huynh avatar Mar 26 '24 00:03 Here2Huynh

@michelengelen is there anyway to get time estimations for the fixes? Thank you!

Not yet ... we have been very busy with the v7 release. We will have a look and provide an estimate as soon as we can. Sry for the delay! 🙇🏼

michelengelen avatar Mar 28 '24 13:03 michelengelen

@michelengelen I don't know if this is appropriate but I would like to add on the request to make the filter panel in column menu to be responsive like the above example as well.

We are planning to rework the slots API and with that we might be able to provide more sophisticated ways of customizing the panels in general (#12568).

michelengelen avatar Mar 28 '24 13:03 michelengelen

@Nitzperetz @Here2Huynh this a workaround that you can do to make it look like this:

responsive-filter-panel

Basically use slotProps. With the sx property of the panel slot, you can conditionally apply styles based on a breakpoint:

const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));

const responsiveFilterPanelStyle = {
    "& .MuiDataGrid-filterForm": {
        flexDirection: "column",
        gap: "1rem",
        alignItems: "flex-start",
    },
    "& .MuiDataGrid-filterForm:first-child .MuiDataGrid-filterFormLogicOperatorInput":
    {
        display: "none",
    },
    "& .MuiFormControl-root": {
        width: "100%",
    },
    "& .MuiDataGrid-filterForm .MuiDataGrid-filterFormDeleteIcon .MuiButtonBase-root":
    {
        alignSelf: "flex-start",
    },
    "& .MuiDataGrid-filterForm .MuiAutocomplete-inputRoot": {
        width: "280px",
    },
};

return (
    <div style={{ height: 400, width: "100%" }}>
        <DataGridPro
            {...data}
            slots={{ toolbar: GridToolbar }}
            slotProps={{
                panel: {
                    sx: isMobile ? responsiveFilterPanelStyle : {},
                },
            }}
        />
    </div>
);

Codesandbox: https://codesandbox.io/p/sandbox/cocky-ellis-qlc77j

9uifranco avatar May 08 '24 17:05 9uifranco

@9uifranco thank you! much appreciated.

Nitzperetz avatar May 09 '24 07:05 Nitzperetz