-
-
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] Fix column dimensions import/export with flex and resizing #4311
[data grid] Fix column dimensions import/export with flex and resizing #4311
Conversation
These are the results for the performance tests:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't be easier to not export values with Infinity
or null
? We can use the default values when restoring.
@@ -136,7 +136,7 @@ export const useGridColumnResize = ( | |||
|
|||
colDefRef.current!.computedWidth = newWidth; | |||
colDefRef.current!.width = newWidth; | |||
colDefRef.current!.flex = undefined; | |||
colDefRef.current!.flex = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change doesn't seem necessary to fix #4310 but makes sense to set 0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I did not do this one, I had the flex coming back on re-import.
Maybe it only occurs in some scenario.
As 0
make sense, I propose to keep it.
It was my 1st idea
|
We could export |
When a column definition have |
I didn't understand this part. But I would always convert |
If we did not convert |
It's simpler to convert all dimensions that have
|
Done |
Fixes #4310
This PR fixes two small bugs raised in #4310
flex: undefined
on this column. This is to make sure that the column is not automatically resized when we re-run the sizing process of all columns (when a new column is created for instance). But when saving the state, thisflex: undefined
is not stored in the JSON, so when restoring, the columns has flex again.Solution: Set
flex: 0
instead offlex: undefined
maxWidth
property equalsInfinity
. ButJSON.stringify(Infinity) === 'null'
. So when restoring it, we havemaxWidth: null
, which is handled likemaxWidth: 0
.It was raised by @m4theushw in #3816 (comment), I thought
maxWidth: null
would work but I was clearly wrong.Solution: Set
maxWidth: 'Infinity'
in the export and parse in correctly on restore.