Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
42c256e
add per-item minimum sizes to grid surfaces
retrofox Aug 19, 2026
39f2b6a
add per-item minimum sizes story to the grid
retrofox Aug 19, 2026
ec8058c
generalize per-item minimums into size limits
retrofox Aug 21, 2026
4723bf3
demonstrate size limits per grid model
retrofox Aug 21, 2026
658b162
Merge remote-tracking branch 'origin/trunk' into update/grid-tile-limits
retrofox Aug 21, 2026
1e19dd6
anchor full-width resize at the capped span
retrofox Aug 21, 2026
9146e28
exercise full and fill widths in the limits story
retrofox Aug 21, 2026
20463e0
plan fill widths around item span bounds
retrofox Aug 21, 2026
b9417ed
tune the limit stories to twelve columns
retrofox Aug 21, 2026
6a7b2d6
Merge branch 'trunk' into update/grid-tile-limits
retrofox Aug 21, 2026
f0ade54
link the grid changelog to its pull request
retrofox Aug 21, 2026
f033787
Merge remote-tracking branch 'origin/trunk' into update/grid-tile-limits
retrofox Aug 23, 2026
93b4260
keep span bounds identity stable across geometry ticks
retrofox Aug 23, 2026
594de0a
place capped full items like fixed items in the fill plan
retrofox Aug 23, 2026
2031dac
document item limits in the grid readme and trim the jsdoc
retrofox Aug 23, 2026
b692591
add a tile bounded on both ends to the size limits stories
retrofox Aug 23, 2026
74112c7
mark the size limits stories as a11y todo
retrofox Aug 23, 2026
d3e0a1a
Merge remote-tracking branch 'origin/trunk' into update/grid-tile-limits
retrofox Aug 26, 2026
73e323d
derive grid commits from the stored layout
retrofox Aug 26, 2026
23d42d7
resize lanes from the rendered span
retrofox Aug 26, 2026
b440755
narrow lanes item limits to the width axis
retrofox Aug 26, 2026
b151ee7
Merge remote-tracking branch 'origin/trunk' into update/grid-tile-limits
retrofox Aug 27, 2026
aacd4ca
Update packages/grid/README.md
retrofox Aug 28, 2026
dfd9ca8
Merge remote-tracking branch 'origin/trunk' into update/grid-tile-limits
retrofox Aug 28, 2026
8840eac
docs: grid height limits need a numeric rowHeight
retrofox Aug 28, 2026
6e732ab
Merge remote-tracking branch 'origin/update/grid-tile-limits' into up…
retrofox Aug 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/grid/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
item is pinned: it cannot be dragged and holds its index while the
other items reorder; a non-resizable item keeps its size
([#81967](https://github.com/WordPress/gutenberg/pull/81967)).
- `DashboardGrid` and `DashboardLanes` accept `itemLimits`: per-item minimum and maximum tile sizes in pixels (`GridItemLimits`; width-only `GridItemWidthLimits` on lanes), enforced on rendered spans and resize gestures without being written into the layout ([#81899](https://github.com/WordPress/gutenberg/pull/81899)).

### Internal

Expand Down
41 changes: 40 additions & 1 deletion packages/grid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ interface DashboardGridLayoutItem {

- `number`: span that many columns (clamped to the grid's column count).
- `'fill'`: fill the remaining columns in the current row.
- `'full'`: span every column (`grid-column: 1 / -1`), forcing a row break.
- `'full'`: span every column and force a row break; an `itemLimits` maximum caps the span.

`'fill'` is resolved per-row against the remaining free space.

Expand All @@ -151,6 +151,7 @@ interface DashboardGridLayoutItem {
| `columns` | `number` | `6` | Total columns (fixed mode). |
| `minColumnWidth` | `number` | — | If set, enables responsive mode: columns derived from container width. Mutually exclusive with `columns`. |
| `rowHeight` | `number \| 'auto'` | `'auto'` | Row height in pixels, or `'auto'` to let content size rows. |
| `itemLimits` | `Record< string, GridItemLimits >` | — | Per-item minimum and maximum tile sizes in pixels, keyed by layout item key. See [Size limits](#size-limits). |
| `editMode` | `boolean` | `false` | Enables drag-to-reorder and resize handles. |
| `onChangeLayout` | `( layout ) => void` | — | Fired when the user commits a drag or resize. |
| `onPreviewLayout` | `( layout ) => void` | — | Fired continuously during a drag or resize with the in-progress layout. Use for live feedback; `onChangeLayout` still emits the committed result. |
Expand Down Expand Up @@ -314,6 +315,7 @@ items flow around them; out-of-range values (negative, or beyond
| `minColumnWidth` | `number` | — | If set, enables responsive mode: lane count derived from container width. Mutually exclusive with `columns`. |
| `flowTolerance` | `number` | `16` | Pixel tolerance for source-order tiebreaking when two candidate lanes have similar baselines. Larger values keep tiles closer to reading order at the cost of bigger empty regions. |
| `rowUnit` | `number` | `4` | Snap unit for the polyfill's `grid-row-start` math. Smaller values produce sharper placement at the cost of a larger implicit row count. Ignored on browsers with native `display: grid-lanes` support. |
| `itemLimits` | `Record< string, GridItemWidthLimits >` | — | Per-item minimum and maximum tile widths in pixels, keyed by layout item key. See [Size limits](#size-limits). |
| `editMode` | `boolean` | `false` | Enables drag-to-reorder and horizontal resize. |
| `onChangeLayout` | `( layout ) => void` | — | Fired when the user commits a drag or resize. |
| `onPreviewLayout` | `( layout ) => void` | — | Fired continuously during a drag or resize. |
Expand Down Expand Up @@ -379,6 +381,43 @@ preview update; the overhead is minor up to ~50 tiles and grows
from there. For `DashboardLanes`, placement runs in a
`useLayoutEffect` throttled to one frame per measurement burst.

### Size limits

`itemLimits` declares per-item floors and ceilings in pixels, keyed by
layout item key:

```jsx
<DashboardGrid
layout={ layout }
rowHeight={ 80 }
itemLimits={ {
chart: { minWidth: 320, minHeight: 200 },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Should the example set a numeric rowHeight? I noticed height limits are skipped when rowHeight is 'auto', which is the default, so minHeight: 200 here may be a no-op.

note: { maxWidth: 500 },
} }
>
{ tiles }
</DashboardGrid>
```

Each surface quantizes a limit to whole tracks of its current
geometry: minimums round up, maximums round down, and a quantized
minimum wins over a smaller quantized maximum. The result bounds the
rendered span and the resize gesture, so a resize never commits a
span outside it.

Limits are not written into the layout. A stored span outside the
limits renders bounded while the stored data stays untouched, so a
limit change applies to every existing layout. A resize commits the
resized tile at its new span and a reorder commits only the order;
every other tile keeps its stored span, even while it renders bounded.

`'full'` and `'fill'` widths respect a maximum: `'full'` renders at the
capped span and places like a fixed item of that width, and `'fill'`
reserves at least its minimum and never exceeds its maximum.
Height limits apply when `rowHeight` is numeric and stay open with
`'auto'` rows. `DashboardLanes` takes `GridItemWidthLimits`: lane
heights are content-driven.

### Accessibility

Drag-to-reorder is operable from the keyboard via `@dnd-kit`'s
Expand Down
18 changes: 14 additions & 4 deletions packages/grid/src/dashboard-grid/grid-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export function GridItem( {
resizeSnapPreview = null,
minResizeWidthPx,
minResizeHeightPx,
maxResizeWidthPx,
maxResizeHeightPx,
renderResizeHandle,
}: GridItemProps ) {
const [ resizeDelta, setResizeDelta ] = useState< ResizeDelta | null >(
Expand Down Expand Up @@ -104,10 +106,18 @@ export function GridItem( {
height: verticalResizable ? delta.height : 0,
};
if ( baselineSize ) {
clamped = clampResizeDelta( clamped, baselineSize, {
width: minResizeWidthPx,
height: verticalResizable ? minResizeHeightPx : undefined,
} );
clamped = clampResizeDelta(
clamped,
baselineSize,
{
width: minResizeWidthPx,
height: verticalResizable ? minResizeHeightPx : undefined,
},
{
width: maxResizeWidthPx,
height: verticalResizable ? maxResizeHeightPx : undefined,
}
);
}
setResizeDelta( clamped );
onResize( item.key, clamped );
Expand Down
Loading
Loading