@@ -114,7 +114,7 @@ export class AdaptiveColumnsController extends modules.ViewController {
114114
115115 private _form ?: Form ;
116116
117- private _hidingColumnsQueue : any ;
117+ private _hidingColumnsQueue ?: Column [ ] ;
118118
119119 protected _keyboardNavigationController ! : KeyboardNavigationController ;
120120
@@ -605,39 +605,41 @@ export class AdaptiveColumnsController extends modules.ViewController {
605605 return editMode === EDIT_MODE_FORM || editMode === EDIT_MODE_POPUP ;
606606 }
607607
608- public hideRedundantColumns ( resultWidths , visibleColumns , hiddenQueue ) {
609- const that = this ;
610-
608+ public hideRedundantColumns (
609+ resultWidths : ( number | string | undefined ) [ ] ,
610+ visibleColumns : Column [ ] ,
611+ hiddenQueue : Column [ ] ,
612+ ) : void {
611613 this . _hiddenColumns = [ ] ;
612614
613- if ( that . _isVisibleColumnsValid ( visibleColumns ) && hiddenQueue . length ) {
615+ if ( this . _isVisibleColumnsValid ( visibleColumns ) && hiddenQueue . length ) {
614616 let totalWidth = 0 ;
615- const $rootElement = that . component . $element ( ) ;
616- let rootElementWidth = getWidth ( $rootElement ) - that . _getCommandColumnsWidth ( ) ;
617+ const $rootElement = this . component . $element ( ) ;
618+ const availableWidth = getWidth ( $rootElement ) - this . _rowsView . getScrollbarWidth ( ) ;
619+ let rootElementWidth = availableWidth - this . _getCommandColumnsWidth ( ) ;
617620 const getVisibleContentColumns = function ( ) {
618621 return visibleColumns . filter ( ( item ) => ! item . command && this . _hiddenColumns . filter ( ( i ) => i . index === item . index ) . length === 0 ) ;
619622 } . bind ( this ) ;
620623 let visibleContentColumns = getVisibleContentColumns ( ) ;
621624 const contentColumnsCount = visibleContentColumns . length ;
622- let i ;
623- let hasHiddenColumns ;
624- let needHideColumn ;
625+ let hasHiddenColumns = false ;
626+ let needHideColumn = false ;
625627
626628 do {
627629 needHideColumn = false ;
628630 totalWidth = 0 ;
629631
630- const percentWidths = that . _calculatePercentWidths ( resultWidths , visibleColumns ) ;
632+ const percentWidths = this . _calculatePercentWidths ( resultWidths , visibleColumns ) ;
631633
632634 const columnsCanFit = percentWidths < 100 && percentWidths !== 0 ;
633- for ( i = 0 ; i < visibleColumns . length ; i ++ ) {
635+ for ( let i = 0 ; i < visibleColumns . length ; i += 1 ) {
634636 const visibleColumn = visibleColumns [ i ] ;
635637
636- let columnWidth = that . _getNotTruncatedColumnWidth ( visibleColumn , rootElementWidth , visibleContentColumns , columnsCanFit ) ;
637- const columnId = getColumnId ( that , visibleColumn ) ;
638- const widthOption = that . _columnsController . columnOption ( columnId , 'width' ) ;
639- const minWidth = that . _columnsController . columnOption ( columnId , 'minWidth' ) ;
640- const columnBestFitWidth = that . _columnsController . columnOption ( columnId , 'bestFitWidth' ) ;
638+ let columnWidth = this . _getNotTruncatedColumnWidth ( visibleColumn , rootElementWidth , visibleContentColumns , columnsCanFit ) ;
639+ const columnId = getColumnId ( this , visibleColumn ) ;
640+ const widthOption = this . _columnsController . columnOption ( columnId , 'width' ) ;
641+ const minWidth = this . _columnsController . columnOption ( columnId , 'minWidth' ) ;
642+ const columnBestFitWidth = this . _columnsController . columnOption ( columnId , 'bestFitWidth' ) ;
641643
642644 if ( resultWidths [ i ] === HIDDEN_COLUMNS_WIDTH ) {
643645 hasHiddenColumns = true ;
@@ -657,15 +659,15 @@ export class AdaptiveColumnsController extends modules.ViewController {
657659 }
658660 }
659661
660- needHideColumn = needHideColumn || totalWidth > getWidth ( $rootElement ) ;
662+ needHideColumn = needHideColumn || totalWidth > availableWidth ;
661663
662664 if ( needHideColumn ) {
663- const column = hiddenQueue . pop ( ) ;
664- const visibleIndex = that . _columnsController . getVisibleIndex ( column . index ) ;
665+ const column = hiddenQueue . pop ( ) as Column ;
666+ const visibleIndex = this . _columnsController . getVisibleIndex ( column . index ) ;
665667
666- rootElementWidth += that . _calculateColumnWidth ( column , rootElementWidth , visibleContentColumns , columnsCanFit ) ;
668+ rootElementWidth += this . _calculateColumnWidth ( column , rootElementWidth , visibleContentColumns , columnsCanFit ) ;
667669
668- that . _hideVisibleColumn ( { visibleIndex } ) ;
670+ this . _hideVisibleColumn ( { visibleIndex } ) ;
669671 resultWidths [ visibleIndex ] = HIDDEN_COLUMNS_WIDTH ;
670672 this . _hiddenColumns . push ( column ) ;
671673 visibleContentColumns = getVisibleContentColumns ( ) ;
@@ -674,10 +676,10 @@ export class AdaptiveColumnsController extends modules.ViewController {
674676 while ( needHideColumn && visibleContentColumns . length > 1 && hiddenQueue . length ) ;
675677
676678 if ( contentColumnsCount === visibleContentColumns . length ) {
677- that . _hideAdaptiveColumn ( resultWidths , visibleColumns ) ;
679+ this . _hideAdaptiveColumn ( resultWidths , visibleColumns ) ;
678680 }
679681 } else {
680- that . _hideAdaptiveColumn ( resultWidths , visibleColumns ) ;
682+ this . _hideAdaptiveColumn ( resultWidths , visibleColumns ) ;
681683 }
682684 }
683685
@@ -793,8 +795,8 @@ export class AdaptiveColumnsController extends modules.ViewController {
793795 return this . _hiddenColumns . length > 0 ;
794796 }
795797
796- public getHidingColumnsQueue ( ) {
797- return this . _hidingColumnsQueue ;
798+ public getHidingColumnsQueue ( ) : Column [ ] {
799+ return this . _hidingColumnsQueue ?? [ ] ;
798800 }
799801
800802 public isAdaptiveDetailRowExpanded ( key ) {
0 commit comments