@@ -116,7 +116,7 @@ export class AdaptiveColumnsController extends modules.ViewController {
116116
117117 private _form ?: Form ;
118118
119- private _hidingColumnsQueue : any ;
119+ private _hidingColumnsQueue ?: Column [ ] ;
120120
121121 protected _keyboardNavigationController ! : KeyboardNavigationController ;
122122
@@ -616,39 +616,41 @@ export class AdaptiveColumnsController extends modules.ViewController {
616616 return editMode === EDIT_MODE_FORM || editMode === EDIT_MODE_POPUP ;
617617 }
618618
619- public hideRedundantColumns ( resultWidths , visibleColumns , hiddenQueue ) {
620- const that = this ;
621-
619+ public hideRedundantColumns (
620+ resultWidths : ( number | string | undefined ) [ ] ,
621+ visibleColumns : Column [ ] ,
622+ hiddenQueue : Column [ ] ,
623+ ) : void {
622624 this . _hiddenColumns = [ ] ;
623625
624- if ( that . _isVisibleColumnsValid ( visibleColumns ) && hiddenQueue . length ) {
626+ if ( this . _isVisibleColumnsValid ( visibleColumns ) && hiddenQueue . length ) {
625627 let totalWidth = 0 ;
626- const $rootElement = that . component . $element ( ) ;
627- let rootElementWidth = getWidth ( $rootElement ) - that . _getCommandColumnsWidth ( ) ;
628+ const $rootElement = this . component . $element ( ) ;
629+ const availableWidth = getWidth ( $rootElement ) - this . _rowsView . getScrollbarWidth ( ) ;
630+ let rootElementWidth = availableWidth - this . _getCommandColumnsWidth ( ) ;
628631 const getVisibleContentColumns = function ( ) {
629632 return visibleColumns . filter ( ( item ) => ! item . command && this . _hiddenColumns . filter ( ( i ) => i . index === item . index ) . length === 0 ) ;
630633 } . bind ( this ) ;
631634 let visibleContentColumns = getVisibleContentColumns ( ) ;
632635 const contentColumnsCount = visibleContentColumns . length ;
633- let i ;
634- let hasHiddenColumns ;
635- let needHideColumn ;
636+ let hasHiddenColumns = false ;
637+ let needHideColumn = false ;
636638
637639 do {
638640 needHideColumn = false ;
639641 totalWidth = 0 ;
640642
641- const percentWidths = that . _calculatePercentWidths ( resultWidths , visibleColumns ) ;
643+ const percentWidths = this . _calculatePercentWidths ( resultWidths , visibleColumns ) ;
642644
643645 const columnsCanFit = percentWidths < 100 && percentWidths !== 0 ;
644- for ( i = 0 ; i < visibleColumns . length ; i ++ ) {
646+ for ( let i = 0 ; i < visibleColumns . length ; i += 1 ) {
645647 const visibleColumn = visibleColumns [ i ] ;
646648
647- let columnWidth = that . _getNotTruncatedColumnWidth ( visibleColumn , rootElementWidth , visibleContentColumns , columnsCanFit ) ;
648- const columnId = getColumnId ( that , visibleColumn ) ;
649- const widthOption = that . _columnsController . columnOption ( columnId , 'width' ) ;
650- const minWidth = that . _columnsController . columnOption ( columnId , 'minWidth' ) ;
651- const columnBestFitWidth = that . _columnsController . columnOption ( columnId , 'bestFitWidth' ) ;
649+ let columnWidth = this . _getNotTruncatedColumnWidth ( visibleColumn , rootElementWidth , visibleContentColumns , columnsCanFit ) ;
650+ const columnId = getColumnId ( this , visibleColumn ) ;
651+ const widthOption = this . _columnsController . columnOption ( columnId , 'width' ) ;
652+ const minWidth = this . _columnsController . columnOption ( columnId , 'minWidth' ) ;
653+ const columnBestFitWidth = this . _columnsController . columnOption ( columnId , 'bestFitWidth' ) ;
652654
653655 if ( resultWidths [ i ] === HIDDEN_COLUMNS_WIDTH ) {
654656 hasHiddenColumns = true ;
@@ -668,15 +670,15 @@ export class AdaptiveColumnsController extends modules.ViewController {
668670 }
669671 }
670672
671- needHideColumn = needHideColumn || totalWidth > getWidth ( $rootElement ) ;
673+ needHideColumn = needHideColumn || totalWidth > availableWidth ;
672674
673675 if ( needHideColumn ) {
674- const column = hiddenQueue . pop ( ) ;
675- const visibleIndex = that . _columnsController . getVisibleIndex ( column . index ) ;
676+ const column = hiddenQueue . pop ( ) as Column ;
677+ const visibleIndex = this . _columnsController . getVisibleIndex ( column . index ) ;
676678
677- rootElementWidth += that . _calculateColumnWidth ( column , rootElementWidth , visibleContentColumns , columnsCanFit ) ;
679+ rootElementWidth += this . _calculateColumnWidth ( column , rootElementWidth , visibleContentColumns , columnsCanFit ) ;
678680
679- that . _hideVisibleColumn ( { visibleIndex } ) ;
681+ this . _hideVisibleColumn ( { visibleIndex } ) ;
680682 resultWidths [ visibleIndex ] = HIDDEN_COLUMNS_WIDTH ;
681683 this . _hiddenColumns . push ( column ) ;
682684 visibleContentColumns = getVisibleContentColumns ( ) ;
@@ -685,10 +687,10 @@ export class AdaptiveColumnsController extends modules.ViewController {
685687 while ( needHideColumn && visibleContentColumns . length > 1 && hiddenQueue . length ) ;
686688
687689 if ( contentColumnsCount === visibleContentColumns . length ) {
688- that . _hideAdaptiveColumn ( resultWidths , visibleColumns ) ;
690+ this . _hideAdaptiveColumn ( resultWidths , visibleColumns ) ;
689691 }
690692 } else {
691- that . _hideAdaptiveColumn ( resultWidths , visibleColumns ) ;
693+ this . _hideAdaptiveColumn ( resultWidths , visibleColumns ) ;
692694 }
693695 }
694696
@@ -806,8 +808,8 @@ export class AdaptiveColumnsController extends modules.ViewController {
806808 return this . _hiddenColumns . length > 0 ;
807809 }
808810
809- public getHidingColumnsQueue ( ) {
810- return this . _hidingColumnsQueue ;
811+ public getHidingColumnsQueue ( ) : Column [ ] {
812+ return this . _hidingColumnsQueue ?? [ ] ;
811813 }
812814
813815 public isAdaptiveDetailRowExpanded ( key ) {
0 commit comments