@@ -1489,30 +1489,34 @@ export class GridStack {
1489
1489
/** @internal */
1490
1490
protected _updateContainerHeight ( ) : GridStack {
1491
1491
if ( ! this . engine || this . engine . batchMode ) return this ;
1492
- let row = this . getRow ( ) + this . _extraDragRow ; // checks for minRow already
1493
- // check for css min height
1494
- // Note: we don't handle %,rem correctly so comment out, beside we don't need need to create un-necessary
1495
- // rows as the CSS will make us bigger than our set height if needed... not sure why we had this.
1496
- // let cssMinHeight = parseInt(getComputedStyle(this.el)['min-height']);
1497
- // if (cssMinHeight > 0) {
1498
- // let minRow = Math.round(cssMinHeight / this.getCellHeight(true));
1499
- // if (row < minRow) {
1500
- // row = minRow;
1501
- // }
1502
- // }
1492
+ const parent = this . parentGridItem ;
1493
+ let row = this . getRow ( ) + this . _extraDragRow ; // this checks for minRow already
1494
+ const cellHeight = this . opts . cellHeight as number ;
1495
+ const unit = this . opts . cellHeightUnit ;
1496
+ if ( ! cellHeight ) return this ;
1497
+
1498
+ // check for css min height (non nested grid). TODO: support mismatch, say: min % while unit is px.
1499
+ if ( ! parent ) {
1500
+ const cssMinHeight = Utils . parseHeight ( getComputedStyle ( this . el ) [ 'minHeight' ] ) ;
1501
+ if ( cssMinHeight . h > 0 && cssMinHeight . unit === unit ) {
1502
+ const minRow = Math . floor ( cssMinHeight . h / cellHeight ) ;
1503
+ if ( row < minRow ) {
1504
+ row = minRow ;
1505
+ }
1506
+ }
1507
+ }
1508
+
1503
1509
this . el . setAttribute ( 'gs-current-row' , String ( row ) ) ;
1504
- if ( row === 0 ) {
1505
- this . el . style . removeProperty ( 'min-height' ) ;
1506
- } else {
1507
- let cellHeight = this . opts . cellHeight as number ;
1508
- let unit = this . opts . cellHeightUnit ;
1509
- if ( ! cellHeight ) return this ;
1510
- this . el . style . minHeight = row * cellHeight + unit ;
1510
+ this . el . style . removeProperty ( 'min-height' ) ;
1511
+ this . el . style . removeProperty ( 'height' ) ;
1512
+ if ( row ) {
1513
+ // nested grids have 'insert:0' to fill the space of parent by default, but we may be taller so use min-height for possible scrollbars
1514
+ this . el . style [ parent ? 'minHeight' : 'height' ] = row * cellHeight + unit ;
1511
1515
}
1512
1516
1513
1517
// if we're a nested grid inside an sizeToContent item, tell it to resize itself too
1514
- if ( this . parentGridItem && ! this . parentGridItem . grid . engine . batchMode && Utils . shouldSizeToContent ( this . parentGridItem ) ) {
1515
- this . parentGridItem . grid . resizeToContentCheck ( this . parentGridItem . el ) ;
1518
+ if ( parent && ! parent . grid . engine . batchMode && Utils . shouldSizeToContent ( parent ) ) {
1519
+ parent . grid . resizeToContentCheck ( parent . el ) ;
1516
1520
}
1517
1521
1518
1522
return this ;
0 commit comments