Skip to content

Add opt-in independentColumnResizing so a resize drag changes only the dragged column #833

Description

@relznot

Current behavior

Column resizing is zero-sum. In DataTableResizableHeaderHandle, a drag grows the dragged column by shrinking its immediate right-hand neighbor by the same amount (setMultipleColumnWidths writes both {accessor, width} entries, delta clamped by Math.max(-maxShrinkCurrent, Math.min(deltaX, maxShrinkNext))). Two consequences:

  1. Widening a column crushes the neighbor, so laying out a wide table means fixing every column downstream of the one being adjusted — each fix steals from the next.
  2. The last column can't be resized at all. Two independent gates enforce this: DataTableHeader strips the prop from the final leaf column (resizable={resizable && index < columns.length - 1}), and the handle's mousedown bails when there is no next resizable sibling to take width from.

Use case

Operators arranging a wide, horizontally-scrolling data table want to size one column without disturbing a layout they already set, and want to widen a column into the existing horizontal scroll rather than at a neighbor's expense. They also expect the rightmost column to be resizable like any other.

Proposed semantics — new opt-in DataTable prop independentColumnResizing?: boolean (default false, preserving today's behavior)

When enabled:

  • A drag writes only the dragged column's width, clamped against its own min width with no upper bound.
  • The table's total width (already the sum of pixel widths under the fixed-layout lock) grows or shrinks into horizontal overflow; neighbors are untouched.
  • Both last-column gates are dropped, so the rightmost column is resizable.
  • Release persists only the dragged column's width.
  • Double-click-to-reset and reset-columns restore the fluid auto layout unchanged.

Accepted trade-off: shrinking columns can leave blank space to the right of the table when the total drops below the viewport width.

We currently ship exactly this as a patch-package patch against 9.4.0 (verified working, including persistence and reset) and would prefer to adopt it as a first-class prop. Happy to open a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions