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.

scrollIntoView doesn't work properly for some cases

See original GitHub issue


Hi there,

I found one issue with the API call - scrollIntoView. For my case, it works most time with a small tree, but does not work for the large tree. So I created my own local function based on the source code below.

TreeNode.prototype.scrollIntoView = function () {
        if (this.elementRef) {
            var nativeElement = this.elementRef.nativeElement;
            nativeElement.scrollIntoViewIfNeeded && nativeElement.scrollIntoViewIfNeeded();
            return this;

I am using scrollIntoView instead of scrollIntoViewIfNeeded, which is also suggested by

My code:

        if (this.focusedNode) {
          if (this.focusedNode.elementRef) {
            let nativeElement = this.focusedNode.elementRef.nativeElement;

It works for both small and large trees.

I hope my finding and solution will be helpful to others.



Issue Analytics

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

github_iconTop GitHub Comments

ottossoncommented, Feb 11, 2018

I’ve got the same issue. scrollIntoView works in Firefox and IE11 for my application, but not in Chrome. I can’t seem to reproduce a working example to show here though.

Here is a broken example where scrollIntoView doesn’t work in any browser I’ve tried with.

phoudecommented, Aug 13, 2018

It did the trick. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

scrollIntoView() doesn't scroll anywhere
I was facing the same issue. scrollIntoView was working only if behavior was auto . Setting a delay fixed some cases but not...
Read more >
Unfortunately scrollIntoView doesn't seem to behave ...
Linux (latest version of KDE): it doesn't work properly. The carousel view is scrolled to the top of the view port, but the...
Read more >
Start using scroll-into-view-if-needed in your project by running `npm i ... on what is the most important to your use case:: load time, ......
Read more >
42593 – element.scrollIntoView() sometimes doesn't scroll
There's an issue open about focus() on the W3C bug tracker [1]. Firefox has another behavior where it decided whether or not to...
Read more >
scrollIntoView issue with vue-router - Hi - Bong's Notes
After googling, it looks like vue-router doesn't work well with scrollTo and sticky div element (link). And I use sticky for my sidebar....
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 Post

No results found

github_iconTop Related Hashnode Post

No results found