Skip to content

Conversation

@Wroud
Copy link
Contributor

@Wroud Wroud commented Feb 26, 2025

#3723

This PR will fix column resize sync. As a side effect, you don't need to pass maxWidth programmatically. You can apply it as a style to the data-measuring-cell elements (so you don't need to check if the resize amount in between max/min size; the browser will handle it)

@Wroud
Copy link
Contributor Author

Wroud commented Feb 26, 2025

I found that setting gridRef.current!.style.gridTemplateColumns will break the react reconciliation mechanism, so props changes in this style will not be applied

@codecov
Copy link

codecov bot commented Feb 26, 2025

Codecov Report

Attention: Patch coverage is 94.23077% with 3 lines in your changes missing coverage. Please review.

Project coverage is 98.66%. Comparing base (79d9662) to head (d02f66d).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/hooks/useColumnWidths.ts 93.33% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3724   +/-   ##
=======================================
  Coverage   98.65%   98.66%           
=======================================
  Files          47       47           
  Lines        3423     3443   +20     
  Branches      742      747    +5     
=======================================
+ Hits         3377     3397   +20     
  Misses         46       46           
Files with missing lines Coverage Δ
src/DataGrid.tsx 99.78% <100.00%> (ø)
src/HeaderRow.tsx 100.00% <ø> (ø)
src/utils/renderMeasuringCells.tsx 100.00% <100.00%> (ø)
src/hooks/useColumnWidths.ts 96.15% <93.33%> (+0.69%) ⬆️

@Wroud
Copy link
Contributor Author

Wroud commented Mar 3, 2025

I've added the [data-measuring-cell] attribute to the measurement cell to support the following use case:

  1. don't set max-width of columns
  2. set the width of columns to 'max-content'
  3. add CSS:
    [data-measuring-cell] { 
      max-width: 400px;
    }
    

This makes it possible to add "auto-size" specific behavior without limiting "functional" behavior:

  1. columns will be sized according to their content
  2. columns can be resized to exceed 400px width
  3. size reset will return the column to its content width (max 400px)

@amanmahajan7
Copy link
Collaborator

Thank you for the PR. I believe this will break existing functionality

amanmahajan7 added a commit that referenced this pull request Apr 8, 2025
Fixes #3723

Root cause: #3724 (comment)
@amanmahajan7
Copy link
Collaborator

Fixed in #3746

@Wroud Wroud deleted the fix/columns-resize-sync branch June 5, 2025 11:25
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.

2 participants