@@ -219,11 +219,13 @@ export function enableColumnResizing(gridElement, resizeColumnOnAllRows = true)
219219 }
220220
221221 const id = gridElement . id ;
222- grids . push ( {
223- id,
224- columns,
225- initialWidths,
226- } ) ;
222+ if ( ! grids . find ( grid => grid . id === id ) ) {
223+ grids . push ( {
224+ id,
225+ columns,
226+ initialWidths,
227+ } ) ;
228+ }
227229
228230 function setListeners ( div , isRTL ) {
229231 let pageX , curCol , curColWidth ;
@@ -351,7 +353,7 @@ export function resetColumnWidths(gridElement) {
351353}
352354
353355export function resizeColumnDiscrete ( gridElement , column , change ) {
354-
356+ const isGrid = gridElement . classList . contains ( 'grid' ) ;
355357 const columns = [ ] ;
356358 let headerBeingResized ;
357359
@@ -369,27 +371,32 @@ export function resizeColumnDiscrete(gridElement, column, change) {
369371
370372 grids . find ( ( { id } ) => id === gridElement . id ) . columns . forEach ( column => {
371373 if ( column . header === headerBeingResized ) {
372- const width = headerBeingResized . getBoundingClientRect ( ) . width + change ;
374+ const width = headerBeingResized . offsetWidth + change ; //. getBoundingClientRect().width + change;
373375
374376 if ( change < 0 ) {
375377 column . size = Math . max ( parseInt ( column . header . style . minWidth ) , width ) + 'px' ;
376378 }
377379 else {
378380 column . size = width + 'px' ;
379381 }
382+ column . header . style . width = column . size ;
380383 }
381- else {
384+ if ( isGrid ) {
385+ // for grid we need to recalculate all columns that are minmax
382386 if ( column . size . startsWith ( 'minmax' ) ) {
383387 column . size = parseInt ( column . header . clientWidth , 10 ) + 'px' ;
384388 }
389+ columns . push ( column . size ) ;
385390 }
386- columns . push ( column . size ) ;
387391 } ) ;
388392
389- gridElement . style . gridTemplateColumns = columns . join ( ' ' ) ;
393+ if ( isGrid ) {
394+ gridElement . style . gridTemplateColumns = columns . join ( ' ' ) ;
395+ }
390396}
391397
392398export function resizeColumnExact ( gridElement , column , width ) {
399+ const isGrid = gridElement . classList . contains ( 'grid' ) ;
393400 const columns = [ ] ;
394401 let headerBeingResized = gridElement . querySelector ( '.column-header[col-index="' + column + '"]' ) ;
395402
@@ -400,16 +407,21 @@ export function resizeColumnExact(gridElement, column, width) {
400407 grids . find ( ( { id } ) => id === gridElement . id ) . columns . forEach ( column => {
401408 if ( column . header === headerBeingResized ) {
402409 column . size = Math . max ( parseInt ( column . header . style . minWidth ) , width ) + 'px' ;
410+ column . header . style . width = column . size ;
403411 }
404- else {
412+ if ( isGrid ) {
413+ // for grid we need to recalculate all columns that are minmax
405414 if ( column . size . startsWith ( 'minmax' ) ) {
406415 column . size = parseInt ( column . header . clientWidth , 10 ) + 'px' ;
407416 }
417+ column . header . style . width = column . size ;
418+ columns . push ( column . size ) ;
408419 }
409- columns . push ( column . size ) ;
410420 } ) ;
411421
412- gridElement . style . gridTemplateColumns = columns . join ( ' ' ) ;
422+ if ( isGrid ) {
423+ gridElement . style . gridTemplateColumns = columns . join ( ' ' ) ;
424+ }
413425
414426 gridElement . dispatchEvent ( new CustomEvent ( 'closecolumnresize' , { bubbles : true } ) ) ;
415427 gridElement . focus ( ) ;
0 commit comments