Uncaught TypeError: Cannot read property 'scrollTop' of null
See original GitHub issueDescribe 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
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Cannot read property 'scrollTop' of null` in a custom hook ...
I made a hook to get the scroll position of a component, like so: function useScrollPosition() { function getScroll() { return { x:...
Read more >Testing Material Ui (v5) Drawer - Cannot read property ...
TypeError : Cannot read property 'scrollTop' of null at reflow ... and the documentation examples of Drawer doesn't pass a ref.
Read more >Uncaught TypeError: Cannot read property 'scrollTop' of null
So, in Eureka , this code works fine: function close_and_reopen_UI_Page() { // Close this current pop-up UI page ...
Read more >caught TypeError: Cannot read property 'scrollTop' of null
caught TypeError: Cannot read property 'scrollTop' of null. Needs review. Project: PDF Reader. Version: 7.x-2.x-dev. Component:.
Read more >Cannot read property 'scrollTop' of null - Ionic Forum
virtualScroll scrollTo generates TypeError: Cannot read property 'scrollTop' of null ... Hi all, New to Ionic here, just love it. SuperSample is ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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)?
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)));