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: columns resize sync #3724

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

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

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)

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