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.

`scrollIntoView` Promise doesn't resolve on some elements

See original GitHub issue

I discovered an apparent bug, where I have something like this:

scrollIntoView([HTMLElement], {
  scrollMode: 'if-needed',
  block: 'nearest',
  boundary: document
}).then(() => { console.log('done') })

It appears that if the element doesn’t need to be scrolled into view (or some other reason?), then the Promise will never resolve. Even if I change .then() to .finally(), nothing happens. No console.log is output. Meaning I can’t chain scrollIntoViews.

I didn’t have this problem until the element I needed to check if it needed to be scrolled into view was sometimes the same height as the document.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
matthew-deancommented, Jul 12, 2018

Thanks for the fast turnaround! It works! ^_^

0reactions
stipsancommented, Jul 18, 2018

I made a repro here: codepen.io/stipsan/pen/gjwWXV

It is showing a behavior similar to what you mentioned above 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

scrollIntoView Promise doesn't resolve on some elements #344
It appears that if the element doesn't need to be scrolled into view (or some other reason?), then the Promise will never resolve....
Read more >
How can I convert scrollIntoView with smooth animation to a ...
Extends Element Objects with a function named scrollIntoViewPromise * options: the normal scrollIntoView options without any changes ...
Read more >
Element.scrollIntoView() - Web APIs | MDN
method scrolls the element's ancestor containers such that the element on which scrollIntoView() is called is visible to the user.
Read more >
scroll-into-view-if-needed - npm
Each action contain a reference to an element that should be scrolled, with its top and left scrolling coordinates. What you return is...
Read more >
read properties of null (reading 'scrollintoview') - You.com
It does not work initially because by the time your component function run there is no elements yet. And it works if there...
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