File tree Expand file tree Collapse file tree
packages/primeng/src/scroller Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -924,10 +924,18 @@ export class Scroller extends BaseComponent<VirtualScrollerPassThrough> {
924924
925925 setSize ( ) {
926926 if ( this . elementViewChild ?. nativeElement ) {
927- const parentElement = this . elementViewChild . nativeElement . parentElement . parentElement ;
928- const width = this . _scrollWidth || `${ this . elementViewChild . nativeElement . offsetWidth || parentElement . offsetWidth } px` ;
929- const height = this . _scrollHeight || `${ this . elementViewChild . nativeElement . offsetHeight || parentElement . offsetHeight } px` ;
930- const setProp = ( _name : string , _value : any ) => ( ( < ElementRef > this . elementViewChild ) . nativeElement . style [ _name ] = _value ) ;
927+ const nativeElement = this . elementViewChild . nativeElement ;
928+ const parentElement = nativeElement . parentElement ?. parentElement ;
929+
930+ const elementWidth = nativeElement . offsetWidth ;
931+ const parentWidth = parentElement ?. offsetWidth || 0 ;
932+ const width = this . _scrollWidth || `${ elementWidth || parentWidth } px` ;
933+
934+ const elementHeight = nativeElement . offsetHeight ;
935+ const parentHeight = parentElement ?. offsetHeight || 0 ;
936+ const height = this . _scrollHeight || `${ elementHeight || parentHeight } px` ;
937+
938+ const setProp = ( _name : string , _value : any ) => ( nativeElement . style [ _name ] = _value ) ;
931939
932940 if ( this . both || this . horizontal ) {
933941 setProp ( 'height' , height ) ;
You can’t perform that action at this time.
0 commit comments