Table of Contents
Mirrored from
/mnt/DATA/git/govoplan-core/docs/DATAGRID_SIZING_CONTRACT.md. Origin:repository. Active tasks and changing state belong in Gitea issues; this wiki page is durable project context.
DataGrid Sizing Contract
DataGrid turns every declared track into a deterministic pixel layout after
its container has a measurable width. The same contract is used on initial
layout, container resize, persisted-layout restore, and pointer resize.
Column Declarations
width: numberorNpxis the preferred pixel width.width: N%is a preferred share of the measured container.width: Nfrshares residual width by fraction weight.width: minmax(Npx, preferred)combines a hard lower bound with any supported preferred width.- An omitted width and the legacy
fillflag are one-fraction flexible tracks. minWidthis a hard floor. Header sort, filter, and resize controls may raise the effective accessible floor.maxWidthbounds direct user growth and free/constrained compensation. In a cover layout it is a preferred maximum: passive tracks may exceed it when that is necessary to keep the table flush with its container.
Layout Modes
initialFit |
resizeBehavior |
Initial layout | Pointer resize |
|---|---|---|---|
container |
cover |
Real columns fill the container. Hard-minimum excess scrolls horizontally. | Growth may create horizontal overflow. Shrink first consumes overflow, then grows resizable columns to the right; it stops before underflow. |
content |
cover |
After measurement, the same cover invariant applies. | Same as cover above. |
container |
constrained |
Real columns fill the container. | Peer compensation respects every hard min/max and stops the active resize when capacity is exhausted. |
content |
free |
Declared content widths are retained. | Only the active column changes, so underflow or horizontal overflow is allowed. |
container |
free |
The initial layout fills the container. | Later user resizing is free. A right-sticky column promotes this mode to cover so its edge remains stable. |
Sticky columns do not absorb ordinary cover residuals and are not resize compensation targets. A last resizable column may grow into overflow. It may shrink only by the current overflow, because shrinking farther would require a blank filler track. Dragging farther past that stop does not bank width changes: the column remains stopped until the pointer crosses the same boundary again.
Persistence
Only the pixel layout resulting from an explicit user resize is persisted, together with the container width at which the user selected it. Persisted widths are keyed by a signature containing column IDs, declared widths and bounds, resize affordances, sticky placement, initial fit, and resize behavior. A changed signature discards the old override and recomputes the declared layout.
Container reconciliation is suspended while a pointer drag is active. On release, the already-rendered pixel layout becomes the persisted preference. Reconciliation at that same container width never shrinks intentional user overflow, so there is no drag-end snap. If the surrounding layout later contracts, persisted tracks may shrink toward their hard minima. The layout retains only the amount of horizontal overflow deliberately created by the user; an exact-cover layout therefore remains exact-cover at narrower widths. Legacy snapshots from the former hard-pixel persistence contract are discarded once and recomputed from the declared column layout.
Regression Matrix
webui/tests/data-grid-sizing.test.ts covers:
- pixel, percentage, fraction,
minmax, omitted, and legacy-fill tracks; - preferred max exhaustion without a synthetic filler column;
- hard-minimum horizontal overflow;
- fixed-only cover grids;
- persisted overrides under growth and viewport pressure;
- responsive contraction of persisted layouts without losing deliberate overflow;
- stale layout signatures;
- first and middle-column right-side compensation;
- last-resizable-column overflow, underflow stop, and reverse-pointer boundary;
- free, cover, and constrained resizing;
- cover-expanded tracks that already exceed preferred maxima; and
- preservation of the pointer layout across the commit fit.
webui/tests/data-grid-actions.test.tsx also verifies the rendered fixed-cover
shape and guards against reintroducing a synthetic buffer cell.