TanStack Table version#
8.20.6
Framework/Library version#
18.3
Describe the bug and the steps to reproduce it#
Take the official full width resizable table example
https://tanstack.com/table/v8/docs/framework/react/examples/full-width-resizable-table
With limited screen space, grow a column, and then grow it some more.
You'll notice that the state now has a ridiculous amount of width, while the column is still fairly small visually.
This means that to size it down_ you now need to drag the handle left a lot without much result.
The solution would be to detect that dragging is over and set the column size to the header element's clientWidth, but I'm not entirely sure how to achieve that.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)#
https://tanstack.com/table/v8/docs/framework/react/examples/full-width-resizable-table
Screenshots or Videos (Optional)#

Do you intend to try to help solve this bug with your own PR?#
No, because I do not have time to dig into it
Terms & Code of Conduct#
The reason this "dead zone" / ghost dragging happens in constrained or full-width layouts is a mismatch between two separate sizing layers:
columnSizingstores raw cumulative pixel offsets calculated directly fromevent.clientX - startX. It increments indefinitely without knowing anything about DOM boundaries or parent container limits.width: 100%/table-layout: fixedor inside a container withoutoverflow-x: auto, the browser's layout engine forcibly clamps the rendered<th>width.If the DOM width is clamped at
180pxbut the user continues dragging right, TanStack's state inflates to500px. When dragging back left, nothing moves visually until the internal state drops below180px.Here are the two ways to solve this cleanly:
Solution 1: Sync Sizing State with DOM
clientWidthon Drag End#Attach a ref to the
<th>cell and wrap the resize handler so that once dragging completes (mouseup/touchend), the column's sizing entry in state is clamped to the actual rendered DOM width (getBoundingClientRect().width):Solution 2: Dynamic
maxSizeConstraint Based on Container Width#If you want to prevent the ghost dragging during the drag (rather than just reconciling on mouse up), enforce an upper bound via
maxSizederived from the available container width:Solution 3: Proper Overflow Architecture (Recommended for Data-Dense Tables)#
If columns are expected to expand freely, the table element itself should be driven by
table.getTotalSize()inside an overflow wrapper rather than constrained bywidth: 100%:When
width: table.getTotalSize()is on the<table>element with horizontal scrolling enabled, DOM widths match the TanStack internal pixel calculations 1:1, eliminating clamping artifacts entirely.