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

fix(react-components): Fix style prop in DataGridCell breaking resizable columns #33503

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ashleylamont
Copy link

@ashleylamont ashleylamont commented Dec 21, 2024

Fix bug where setting the style prop on a data grid cell causes column resizing to fail, and add a test for this.

Previous Behavior

When using DataGridCell with resizable columns, if the user sets the style prop on the DataGridCell, it fails to apply width to the cells.

In a Data Grid with reusable columns, even a blank style object or one with unrelated props, would stop width from being applied. For example:

<DataGridCell style={{color: 'red'}}>
  {/*...*/}
</DataGridCell>

New Behavior

DataGridCell should now merge styles from user-supplied component props, and resizable column data grid cell props, so that it no longer fails to apply styles or control cell width.

In the above example, this would now be merged to a final style prop including the color attribute, as well as min-width, width, etc. from the resizable columns styles.

A test has also been introduced to validate this new behaviour and guard against regressions. It checks that:

  • In cases where either the user, or getTableCellProps defines a style, but not the other, it uses that style
  • In cases where both the user and getTableCellProps define a style, it defers to the user's style value for that CSS property

Related Issue(s)

  • No related issues

…n resizing to fail, and add a test for this.
@ashleylamont ashleylamont force-pushed the users/ashleylamont/fix-datagrid-cell-style-props branch from c994a0d to 6aaf77f Compare December 21, 2024 03:41
@ashleylamont ashleylamont changed the title fix(react-components): Fix bug where fix(react-components): Fix style prop in DataGridCell breaking resizable columns Dec 21, 2024
@ashleylamont ashleylamont marked this pull request as ready for review December 21, 2024 03:50
@ashleylamont ashleylamont requested a review from a team as a code owner December 21, 2024 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant