Skip to content
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

[DataGrid] Allow to control the grid density #12332

Merged
merged 16 commits into from Mar 19, 2024

Conversation

MBilalShafi
Copy link
Member

@MBilalShafi MBilalShafi commented Mar 5, 2024

Resolves #5647

Changelog

Breaking changes

  • The density is a controlled prop now, if you were previously passing the density prop to the Data Grid, you will need to do one of the following:
  1. Move it to the initialState.density to initialize it.

    <DataGrid
    -  density="compact"
    +  initialState={{ density: "compact" }}
    />
  2. Move it to the state and use onDensityChange callback to update the density prop accordingly for it to work as expected.

    + const [density, setDensity] = React.useState<GridDensity>('compact');
    <DataGrid
    -  density="compact"
    +  density={density}
    +  onDensityChange={(newDensity) => setDensity(newDensity)}
    />
  • The selector gridDensityValueSelector was removed, use the gridDensitySelector instead.

@MBilalShafi MBilalShafi added component: data grid This is the name of the generic UI component, not the React module! customization: extend Logic customizability enhancement This is not a bug, nor a new feature labels Mar 5, 2024
@mui-bot
Copy link

mui-bot commented Mar 5, 2024

Co-authored-by: Flavien DELANGLE <flaviendelangle@gmail.com>
Signed-off-by: Bilal Shafi <bilalshafidev@gmail.com>
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 12, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@MBilalShafi
Copy link
Member Author

MBilalShafi commented Mar 12, 2024

Update: I may have to rework this to make it a proper controlled model

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Mar 18, 2024
@MBilalShafi MBilalShafi marked this pull request as ready for review March 18, 2024 09:19
@MBilalShafi MBilalShafi changed the title [DataGrid] Add event callback on density change [DataGrid] Allow to control the grid density Mar 19, 2024
MBilalShafi and others added 3 commits March 19, 2024 17:33
Co-authored-by: Andrew Cherniavskii <andrew.cherniavskii@gmail.com>
Signed-off-by: Bilal Shafi <bilalshafidev@gmail.com>
@MBilalShafi MBilalShafi merged commit d968a63 into mui:next Mar 19, 2024
17 checks passed
@MBilalShafi MBilalShafi deleted the density-callback branch March 19, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: data grid This is the name of the generic UI component, not the React module! customization: extend Logic customizability enhancement This is not a bug, nor a new feature v7.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] Add event callback on density change
4 participants