@@ -1949,43 +1949,45 @@ export class MultipleSelectInstance {
1949
1949
1950
1950
// calculate the "Select All" element width, this text is configurable which is why we recalculate every time
1951
1951
const selectAllSpanElm = this . dropElm . querySelector < HTMLSpanElement > ( '.ms-select-all span' ) ;
1952
- const dropUlElm = this . dropElm . querySelector ( 'ul' ) as HTMLUListElement ;
1952
+ const dropUlElm = this . dropElm . querySelector < HTMLUListElement > ( 'ul' ) ;
1953
1953
1954
- const liPadding = 26 ; // there are multiple padding involved, let's fix it at 26px
1954
+ if ( dropUlElm ) {
1955
+ const liPadding = 26 ; // there are multiple padding involved, let's fix it at 26px
1955
1956
1956
- const selectAllElmWidth = selectAllSpanElm ?. clientWidth ?? 0 + liPadding ;
1957
- const hasScrollbar = dropUlElm . scrollHeight > dropUlElm . clientHeight ;
1958
- const scrollbarWidth = hasScrollbar ? this . getScrollbarWidth ( ) : 0 ;
1959
- let contentWidth = 0 ;
1957
+ const selectAllElmWidth = selectAllSpanElm ?. clientWidth ?? 0 + liPadding ;
1958
+ const hasScrollbar = dropUlElm . scrollHeight > dropUlElm . clientHeight ;
1959
+ const scrollbarWidth = hasScrollbar ? this . getScrollbarWidth ( ) : 0 ;
1960
+ let contentWidth = 0 ;
1960
1961
1961
- this . dropElm . querySelectorAll ( 'li label' ) . forEach ( elm => {
1962
- if ( elm . scrollWidth > contentWidth ) {
1963
- contentWidth = elm . scrollWidth ;
1964
- }
1965
- } ) ;
1962
+ this . dropElm . querySelectorAll ( 'li label' ) . forEach ( elm => {
1963
+ if ( elm . scrollWidth > contentWidth ) {
1964
+ contentWidth = elm . scrollWidth ;
1965
+ }
1966
+ } ) ;
1966
1967
1967
- // add a padding & include the browser scrollbar width
1968
- contentWidth += liPadding + scrollbarWidth ;
1968
+ // add a padding & include the browser scrollbar width
1969
+ contentWidth += liPadding + scrollbarWidth ;
1969
1970
1970
- // make sure the new calculated width is wide enough to include the "Select All" text (this text is configurable)
1971
- if ( contentWidth < selectAllElmWidth ) {
1972
- contentWidth = selectAllElmWidth ;
1973
- }
1971
+ // make sure the new calculated width is wide enough to include the "Select All" text (this text is configurable)
1972
+ if ( contentWidth < selectAllElmWidth ) {
1973
+ contentWidth = selectAllElmWidth ;
1974
+ }
1974
1975
1975
- // if a maxWidth is defined, make sure our new calculate width is not over the maxWidth
1976
- if ( this . options . maxWidth && contentWidth > this . options . maxWidth ) {
1977
- contentWidth = this . options . maxWidth ;
1978
- }
1976
+ // if a maxWidth is defined, make sure our new calculate width is not over the maxWidth
1977
+ if ( this . options . maxWidth && contentWidth > this . options . maxWidth ) {
1978
+ contentWidth = this . options . maxWidth ;
1979
+ }
1979
1980
1980
- // if a minWidth is defined, make sure our new calculate width is not below the minWidth
1981
- if ( this . options . minWidth && contentWidth < this . options . minWidth ) {
1982
- contentWidth = this . options . minWidth ;
1983
- }
1981
+ // if a minWidth is defined, make sure our new calculate width is not below the minWidth
1982
+ if ( this . options . minWidth && contentWidth < this . options . minWidth ) {
1983
+ contentWidth = this . options . minWidth ;
1984
+ }
1984
1985
1985
- // finally re-adjust the drop to the new calculated width when necessary
1986
- if ( currentDefinedWidth === '100%' || + currentDefinedWidth < contentWidth ) {
1987
- this . dropElm . style . width = `${ contentWidth } px` ;
1988
- this . dropElm . style . maxWidth = `${ contentWidth } px` ;
1986
+ // finally re-adjust the drop to the new calculated width when necessary
1987
+ if ( currentDefinedWidth === '100%' || + currentDefinedWidth < contentWidth ) {
1988
+ this . dropElm . style . width = `${ contentWidth } px` ;
1989
+ this . dropElm . style . maxWidth = `${ contentWidth } px` ;
1990
+ }
1989
1991
}
1990
1992
}
1991
1993
}
0 commit comments