ng-select: Uncaught TypeError: Cannot read property 'scrollTop' of null
Describe the bug
I have an angular app with a component which has encapsulation set to ViewEncapsulation.ShadowDom. Inside the template of this component I’m using a ng-select component. Through items input I’m passing 15 items to ng-select component.
I’m getting an error in the console when:
- I click 
ng-selectcomponent and scroll down in the dropdown - I click 
ng-selectcomponent, select one of the first top items in the dropdown and then click on it again. 
Error that I’m getting is:
Uncaught TypeError: Cannot read property 'scrollTop' of null
Through my testing I have noticed that this error appears when:
- a component with 
encapsulationset toViewEncapsulation.ShadowDomis using ang-selectcomponent in its template and - is passing to it an array of items long enough that it creates a scroll bar in a dropdown
 
I’m setting encapsulation to ViewEncapsulation.ShadowDom because this solves some problems when I’m using the component for @angular/elements.
Reproducible example Example which reproduces described behaviour
To Reproduce Steps to reproduce the behavior:
- Clone or download the repository provided in reproducible example
 - Build and serve the app using 
ng servecommand - Do the steps described above
 
About this issue
- Original URL
 - State: closed
 - Created 5 years ago
 - Reactions: 5
 - Comments: 18 (5 by maintainers)
 
Commits related to this issue
- fix: use composePath while handling scroll closes #1317 — committed to ng-select/ng-select by varnastadeus 4 years ago
 - fix: use composePath while handling scroll (#1758) closes #1317 — committed to ng-select/ng-select by varnastadeus 4 years ago
 
Looks like issue is fixed only in master. We are still using angular8 so is there any plan to apply this fix to 3.x branch (and other branches)?
The error also exists in (current) Version 10.0.4 of ng-select with Angular 15.2.x with enabled ViewEncapsulation.ShadowDom.
I’m pretty sure the error was fixed before but is back since several versions, but it may also be that I have not noticed it.
Please re-open the issue again. Thx!
same issue here when using ViewEncapsulation.ShadowDom
File webpack:///./node_modules/@ng-select/ng-select/fesm2015/ng-select-ng-select.js.pre-build-optimizer.js line 2264 col 53 in l._next (e) => this._onContentScrolled(e.target.scrollTop)));Hello,
we’re also encountering the same issue when using
ViewEncapsulation.ShadowDom/Angular ElementsCan confirm that the bug still exists inside ShadowDom elements.