Skip to content

fix(layout): honour a definite grid row when the column is auto - #138

Open
danperks wants to merge 1 commit into
lucid-softworks:mainfrom
danperks:fix/grid-definite-row-auto-column
Open

danperks wants to merge 1 commit into
lucid-softworks:mainfrom
danperks:fix/grid-definite-row-auto-column

Conversation

@danperks

Copy link
Copy Markdown

Grid placement only took the explicit-row path when the column was also explicit:

let (final_r, final_c) = if let Some(c) = col {
    let r = row_opt.unwrap_or(cursor_r);
    (r, c)
} else {
    // auto-place: find next free cell row-major

So an item with grid-row: 3 and no grid-column fell through to row-major auto-placement, which starts from the cursor and steps down a row whenever it runs out of columns — discarding the row the item asked for and leaving it in row 1.

A definite row with an auto column now fixes the row and searches only for a free column within it. Where the row has no free slot the spec grows the grid with implicit columns; those aren't sized here, so the start is clamped to keep the item inside the explicit tracks rather than indexing past them.

The item still marks its cell occupied, so later auto-placed items flow around it instead of stacking on top — the second assertion in the test covers that, since a fix that only positioned the item without recording the cell would leave them overlapping.

Verification

cargo test --workspace passes; the new test fails without the change (pinned item should sit in row 3 at y+40, got 0).

Confirmed end-to-end through WebDriver: in a 5×5 explicit grid, grid-row: 3 now measures at y+40 in the first column, where it previously measured at the origin.

This also completes the single-value grid-area form from #137 — that PR parses grid-area: 3 into a definite row with an auto column, which is exactly the case this fixes. The two are independent and merge cleanly in either order; with both applied, grid-area: 3 lands in row 3.

Made with Cursor

Placement only took the explicit-row path when the column was also
explicit. An item with `grid-row: 3` and no `grid-column` fell through to
row-major auto-placement, which starts from the cursor and steps down a row
whenever it runs out of columns — discarding the row the item asked for and
leaving it in row 1.

A definite row with an auto column fixes the row and searches only for a
free column within it. Where the row has no free slot the spec grows the
grid with implicit columns; those aren't sized here, so the start is clamped
to keep the item inside the explicit tracks rather than indexing past them.

The item still marks its cell occupied, so later auto-placed items flow
around it instead of stacking on top.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant