From 2b6ed2a6d93a028720ccd7ec916ba6692b3eb64c Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Wed, 27 Sep 2023 07:53:11 -0700 Subject: [PATCH] "Invalid height" error CSS minHeight * fix #2469 --- doc/CHANGES.md | 1 + spec/e2e/html/2469_min-height.html | 41 ++++++++++++++++++++++++++++++ src/utils.ts | 13 ++++++---- 3 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 spec/e2e/html/2469_min-height.html diff --git a/doc/CHANGES.md b/doc/CHANGES.md index bcc3508f3..7f22b0b14 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -102,6 +102,7 @@ Change log ## 9.2.1-dev (TBD) * fix - sub-grid styles now look for immediate correct parent, not any depth above. +* fix [#2469](https://github.com/gridstack/gridstack.js/issues/2469) "Invalid height" error CSS minHeight ## 9.2.1 (2023-09-20) * fix _updateContainerHeight() to use height rather than min-height again (apart for nested grids which need it) and partial getComputedStyle CSS minHeight support diff --git a/spec/e2e/html/2469_min-height.html b/spec/e2e/html/2469_min-height.html new file mode 100644 index 000000000..8eddf1270 --- /dev/null +++ b/spec/e2e/html/2469_min-height.html @@ -0,0 +1,41 @@ + + + + + + + Flex display test #2469 + + + + + + + +

Flex display test #2469

+
+
+
+ + + + diff --git a/src/utils.ts b/src/utils.ts index 3da85af18..ee2c7692f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -211,12 +211,15 @@ export class Utils { let h: number; let unit = 'px'; if (typeof val === 'string') { - let match = val.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%)?$/); - if (!match) { - throw new Error('Invalid height'); + if (val === 'auto') h = 0; + else { + let match = val.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%)?$/); + if (!match) { + throw new Error('Invalid height'); + } + unit = match[2] || 'px'; + h = parseFloat(match[1]); } - unit = match[2] || 'px'; - h = parseFloat(match[1]); } else { h = val; }