Skip to content

fix: grid column widths resetting when pin state changes - #1552

Merged
sorenbs merged 1 commit into
mainfrom
fix/1371-column-resizing
Jul 18, 2026
Merged

fix: grid column widths resetting when pin state changes#1552
sorenbs merged 1 commit into
mainfrom
fix/1371-column-resizing

Conversation

@sorenbs

@sorenbs sorenbs commented Jul 18, 2026

Copy link
Copy Markdown
Member

Fixes #1371

Root cause

Column resizing itself works (TanStack onChange resize, 50–400px clamp, per-table state) — but the "reset column order/pinning/sizing when column identities change" effect in DataGrid.tsx lists defaultColumnPinning in its deps, and that memo's identity changes whenever the pinnedColumnIds prop changes, which happens on every pin/unpin (pinning round-trips through URL state). Result, reproduced live: resize a column, pin or unpin any column → all column widths and custom column order silently reset. This alone makes resizing feel broken.

Fix

Guard the reset effect with a ref of the last-seen column-identity key so it only fires when the column-id set actually changes.

Verification

  • New regression test ("keeps user column sizing when pinned columns change") — fails without the fix, passes with it; full grid suite (118 tests) green.
  • Re-verified end-to-end in the live demo: widths now survive both pin and unpin. Typecheck/lint clean; changeset included.

Remaining observations from the investigation (not addressed here, noted on the issues): widths still reset on remount so per-table persistence never survives switching tables; the 400px max cap may read as "broken" for wide JSON columns; the resize handle's effective hit area is ~8px and missing it starts a drag-reorder (relates to #1372).

🤖 Generated with Claude Code

Resizing a column and then pinning or unpinning any column wiped all
user column widths (and custom column order) back to defaults. The
"reset on column identity change" effect in DataGrid depends on
defaultColumnPinning, whose identity also changes whenever the
URL-backed pinnedColumnIds prop round-trips after a pin update, so the
effect re-ran and cleared columnSizing/columnOrder state.

Guard the reset with the column definition identity key so it only
fires when the set of columns actually changes (issue #1371).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e0c209c9-0872-4e5a-bb28-ef214ab28496

📥 Commits

Reviewing files that changed from the base of the PR and between 81354ff and 64f8e20.

📒 Files selected for processing (3)
  • .changeset/grid-column-sizing-survives-pinning.md
  • ui/studio/grid/DataGrid.pinning.test.tsx
  • ui/studio/grid/DataGrid.tsx

Summary by CodeRabbit

  • Bug Fixes
    • Preserved custom column widths and ordering when pinning or unpinning columns.
    • Ensured pinned columns remain sticky without resetting other grid layout preferences.
  • Tests
    • Added coverage verifying that resized columns retain their widths after pinning changes.

Walkthrough

Updated DataGrid reset logic so column order, pinning, and sizing reset only when the column identity changes. Added a controlled pinning regression test confirming a resized column remains at 320px after pinning changes, and added a patch changeset documenting the fix.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: grid column widths no longer reset when pin state changes.
Description check ✅ Passed The description is directly related to the PR and explains the bug, fix, and verification steps.
Linked Issues check ✅ Passed The PR addresses issue #1371 by fixing the reset behavior that made resized column widths appear broken after pinning changes.
Out of Scope Changes check ✅ Passed The changes are in scope: a targeted DataGrid fix, a regression test, and a changeset documenting the behavior change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1371-column-resizing
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/1371-column-resizing

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Compute preview deployed.

Branch: fix/1371-column-resizing
Service: fix-1371-column-resizing
Preview: https://vuaq836q4svlbud7tm71ia99.cdg.prisma.build

@sorenbs

sorenbs commented Jul 18, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@sorenbs
sorenbs merged commit 3f4d84c into main Jul 18, 2026
3 checks passed
@sorenbs
sorenbs deleted the fix/1371-column-resizing branch July 18, 2026 13:04
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.

Column resizing seems to be broken.

1 participant