Skip to content

Commit 56b0bf6

Browse files
authored
Merge pull request #2471 from adumesny/master
"Invalid height" error CSS minHeight
2 parents 0e5b9a0 + 2b6ed2a commit 56b0bf6

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Change log
102102

103103
## 9.2.1-dev (TBD)
104104
* fix - sub-grid styles now look for immediate correct parent, not any depth above.
105+
* fix [#2469](https://github.com/gridstack/gridstack.js/issues/2469) "Invalid height" error CSS minHeight
105106

106107
## 9.2.1 (2023-09-20)
107108
* fix _updateContainerHeight() to use height rather than min-height again (apart for nested grids which need it) and partial getComputedStyle CSS minHeight support

spec/e2e/html/2469_min-height.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>Flex display test #2469</title>
8+
9+
<link rel="stylesheet" href="../../../demo/demo.css" />
10+
<script src="../../../dist/gridstack-all.js"></script>
11+
<style type="text/css">
12+
.some-flex-wrapper {
13+
display: flex;
14+
flex-direction: column;
15+
}
16+
</style>
17+
18+
</head>
19+
<body>
20+
<h1>Flex display test #2469</h1>
21+
<div class="some-flex-wrapper">
22+
<div class="grid-stack"></div>
23+
</div>
24+
<script src="events.js"></script>
25+
<script type="text/javascript">
26+
let grid = GridStack.init({
27+
disableOneColumnMode: true,
28+
float: false,
29+
cellHeight: '120px',
30+
minRow: 1,
31+
margin: 10,
32+
});
33+
34+
let items = [
35+
{x: 1, y: 1, content:'0'},
36+
{x: 2, y: 2, w: 3, content:'1'},
37+
];
38+
grid.load(items);
39+
</script>
40+
</body>
41+
</html>

src/utils.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,15 @@ export class Utils {
211211
let h: number;
212212
let unit = 'px';
213213
if (typeof val === 'string') {
214-
let match = val.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%)?$/);
215-
if (!match) {
216-
throw new Error('Invalid height');
214+
if (val === 'auto') h = 0;
215+
else {
216+
let match = val.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%)?$/);
217+
if (!match) {
218+
throw new Error('Invalid height');
219+
}
220+
unit = match[2] || 'px';
221+
h = parseFloat(match[1]);
217222
}
218-
unit = match[2] || 'px';
219-
h = parseFloat(match[1]);
220223
} else {
221224
h = val;
222225
}

0 commit comments

Comments
 (0)