Skip to content

Commit

Permalink
Grid resize: remove shorthand, serialize other longhand when not auto (
Browse files Browse the repository at this point in the history
…#6581)

**Problem:**

If a grid is configured with the `gridTemplate` shorthand, resizing the
grid does not handle that correctly.

**Fix:**

This PR handles `gridTemplate` shorthands during template changes via
the canvas.
**An incremental PR will do the same for the inspector template
editing**.

For example, if a grid is configured as follows: `gridTemplate: 1fr 2fr
/ 3fr 4fr`, changing its first column to `3.5fr` will result in the
following style:
```
gridTemplateColumns: '3.5fr 4fr',
gridTemplateRows: '1fr 2fr'
```

If a grid has a shorthand with an axis being the default (a single
`auto` keyword), for example `gridTemplate: auto / 3fr 4fr`, the same
change as above will result in:
```
gridTemplateColumns: '3.5fr 4fr',
```

Fixes #6580
  • Loading branch information
ruggi authored and liady committed Dec 13, 2024
1 parent e1335e6 commit a382e75
Show file tree
Hide file tree
Showing 4 changed files with 429 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -788,3 +788,12 @@ export function findOriginalGrid(

return findOriginalGrid(metadata, parentPath)
}

// Returns whether the given dimensions are made of just one item, being a CSS keyword with value "auto".
export function isJustAutoGridDimension(dimensions: GridDimension[]): boolean {
return (
dimensions.length === 1 &&
dimensions[0].type === 'KEYWORD' &&
dimensions[0].value.value === 'auto'
)
}
Loading

0 comments on commit a382e75

Please sign in to comment.