-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Feature: Add support for flex column width #2839
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2839 +/- ##
==========================================
+ Coverage 94.02% 94.35% +0.32%
==========================================
Files 38 38
Lines 1256 1258 +2
Branches 403 405 +2
==========================================
+ Hits 1181 1187 +6
+ Misses 75 71 -4
|
left: number; | ||
} | ||
|
||
const DEFAULT_COLUMN_WIDTH = 'auto'; |
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.
if (typeof width === 'number') { | ||
return width; | ||
} | ||
if (typeof width === 'string' && /^\d+%$/.test(width)) { |
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.
No longer needed as we get the width after the columns are rendered
Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com>
Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com>
Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com>
This reverts commit 151d724.
## [5.1.0](v5.0.4...5.1.0) (2024-01-10) ### Features * Add DataGridComponentsProvider component and DataGrid.components prop ([Comcast#2754](https://github.com/superform-xyz/react-data-grid/issues/2754)) ([f864291](f864291)) * Add support for flex column width ([Comcast#2839](https://github.com/superform-xyz/react-data-grid/issues/2839)) ([4a136ad](4a136ad)) * expose scroll event ([Comcast#2011](https://github.com/superform-xyz/react-data-grid/issues/2011)) ([7614c8e](7614c8e)) * RTL ([Comcast#2803](https://github.com/superform-xyz/react-data-grid/issues/2803)) ([c0e4a63](c0e4a63)) * semantic release installed and configured ([e71bfe6](e71bfe6)) ### Bug Fixes * drag jumps to the right due to the failed merge ([Comcast#1564](https://github.com/superform-xyz/react-data-grid/issues/1564)) ([7033a1b](7033a1b)) * isSelectedCellEditable row getter idx ([Comcast#1743](https://github.com/superform-xyz/react-data-grid/issues/1743)) ([018f137](018f137)) * package-lock.json added to version control ([df39113](df39113)) ### Reverts * Revert "Dependabot: set versioning-strategy to increase (Comcast#2479)" (Comcast#2511) ([0bedc81](0bedc81))
## [5.1.0](v5.0.4...5.1.0) (2024-01-10) ### Features * Add DataGridComponentsProvider component and DataGrid.components prop ([Comcast#2754](https://github.com/superform-xyz/react-data-grid/issues/2754)) ([f864291](f864291)) * Add support for flex column width ([Comcast#2839](https://github.com/superform-xyz/react-data-grid/issues/2839)) ([4a136ad](4a136ad)) * expose scroll event ([Comcast#2011](https://github.com/superform-xyz/react-data-grid/issues/2011)) ([7614c8e](7614c8e)) * RTL ([Comcast#2803](https://github.com/superform-xyz/react-data-grid/issues/2803)) ([c0e4a63](c0e4a63)) * semantic release installed and configured ([e71bfe6](e71bfe6)) ### Bug Fixes * drag jumps to the right due to the failed merge ([Comcast#1564](https://github.com/superform-xyz/react-data-grid/issues/1564)) ([7033a1b](7033a1b)) * isSelectedCellEditable row getter idx ([Comcast#1743](https://github.com/superform-xyz/react-data-grid/issues/1743)) ([018f137](018f137)) * package-lock.json added to version control ([df39113](df39113)) ### Reverts * Revert "Dependabot: set versioning-strategy to increase (Comcast#2479)" (Comcast#2511) ([0bedc81](0bedc81))
* Add support for "auto" width * Calculate columns when grid width is set * Remove unnecessary code * Add support for css column units (fr, %, max-content) * Bring back virtualization * Remove console * Fix minWidth and examples * Add min width * Disable @typescript-eslint/naming-convention * Add comments * Revent some changes * Use getBoundingClientRect * Rename variables * support flex width on all the columns * Fix tests * Update src/DataGrid.tsx Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com> * Address a few comments * Move width type close to minWidth * Do not reset max-content columns * Remove flexColumnWidths state * Add max-content example * Update src/DataGrid.tsx Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com> * Fix classname * Update src/hooks/useGridDimensions.ts Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com> * Remove useMemo * Add back useMemo * tweak autosizeColumnsClassname for better measuring * Revert "tweak autosizeColumnsClassname for better measuring" This reverts commit 151d724. Co-authored-by: Aman Mahajan <amahajan@freewheel.tv> Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com> Co-authored-by: Nicolas Stepien <stepien.nicolas@gmail.com>
Column now supports CSS grid units including
auto
(default),fr
,%
,max-content
etc. To handle virtualization, a flex column is assigned a width of (80px) and the actual width is calculated after the grid is rendered.