@@ -600,12 +600,15 @@ export class GridStack {
600600 ( ! forcePixel || ! this . opts . cellHeightUnit || this . opts . cellHeightUnit === 'px' ) ) {
601601 return this . opts . cellHeight as number ;
602602 }
603- // else do entire grid and # of rows
604- // or get first cell height ?
605- // let el = this.el.querySelector('.' + this.opts.itemClass) as HTMLElement;
606- // let height = Utils.toNumber(el.getAttribute('gs-h'));
607- // return Math.round(el.offsetHeight / height);
608- return Math . round ( this . el . getBoundingClientRect ( ) . height ) / parseInt ( this . el . getAttribute ( 'gs-current-row' ) ) ;
603+ // else get first cell height
604+ let el = this . el . querySelector ( '.' + this . opts . itemClass ) as HTMLElement ;
605+ if ( el ) {
606+ let height = Utils . toNumber ( el . getAttribute ( 'gs-h' ) ) ;
607+ return Math . round ( el . offsetHeight / height ) ;
608+ }
609+ // else do entire grid and # of rows (but doesn't work if min-height is the actual constrain)
610+ let rows = parseInt ( this . el . getAttribute ( 'gs-current-row' ) ) ;
611+ return rows ? Math . round ( this . el . getBoundingClientRect ( ) . height / rows ) : this . opts . cellHeight as number ;
609612 }
610613
611614 /**
@@ -1238,13 +1241,15 @@ export class GridStack {
12381241 if ( ! this . engine || this . engine . batchMode ) return this ;
12391242 let row = this . getRow ( ) + this . _extraDragRow ; // checks for minRow already
12401243 // check for css min height
1241- let cssMinHeight = parseInt ( getComputedStyle ( this . el ) [ 'min-height' ] ) ;
1242- if ( cssMinHeight > 0 ) {
1243- let minRow = Math . round ( cssMinHeight / this . getCellHeight ( true ) ) ;
1244- if ( row < minRow ) {
1245- row = minRow ;
1246- }
1247- }
1244+ // Note: we don't handle %,rem correctly so comment out, beside we don't need need to create un-necessary
1245+ // rows as the CSS will make us bigger than our set height if needed... not sure why we had this.
1246+ // let cssMinHeight = parseInt(getComputedStyle(this.el)['min-height']);
1247+ // if (cssMinHeight > 0) {
1248+ // let minRow = Math.round(cssMinHeight / this.getCellHeight(true));
1249+ // if (row < minRow) {
1250+ // row = minRow;
1251+ // }
1252+ // }
12481253 this . el . setAttribute ( 'gs-current-row' , String ( row ) ) ;
12491254 if ( row === 0 ) {
12501255 this . el . style . removeProperty ( 'height' ) ;
0 commit comments