question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught TypeError: Cannot read property 'scrollTop' of null

See original GitHub issue

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-select component and scroll down in the dropdown
  • I click ng-select component, 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 encapsulation set to ViewEncapsulation.ShadowDom is using a ng-select component 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:

  1. Clone or download the repository provided in reproducible example
  2. Build and serve the app using ng serve command
  3. Do the steps described above

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
snehal4itcommented, Jan 29, 2021

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

3reactions
bartescommented, Dec 2, 2019

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found