`scrollIntoView` Promise doesn't resolve on some elements
See original GitHub issueI 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 scrollIntoView
s.
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:
- Created 5 years ago
- Comments:11 (7 by maintainers)
Top 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 >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 FreeTop 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
Top GitHub Comments
Thanks for the fast turnaround! It works! ^_^
I made a repro here: codepen.io/stipsan/pen/gjwWXV
It is showing a behavior similar to what you mentioned above 🤔