-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scrollIntoView
Promise doesn't resolve on some elements
#344
scrollIntoView
Promise doesn't resolve on some elements
#344
Comments
Hey there! Are you talking about |
@stipsan Yes, that's what I'm using. |
Alright. Then it's for sure a bug. It's always returning a Promise.all: If |
Fixes use cases where code like this might never resolve: ```js scrollIntoView([HTMLElement], { scrollMode: 'if-needed', block: 'nearest' }).then(() => { console.log('done') }) ``` Fixes scroll-into-view/scroll-into-view-if-needed#344
I just released v1.1.13 with a fix, let me know if it works 😄 |
I'm open for feedback on what is returned when the promise resolved. It might make sense to include the same array of actions that it's mapping through? |
Thanks for the fast turnaround! It works! ^_^ |
What it passes to the |
Alright, good news! 😄👍 |
One thing that I'm seeing now. Although now an element that doesn't need scrolling returns a promise, it only resolves after the timeout, even though no scrolling happened. I would expect that if no scrolling needs to happen, then it resolves immediately. |
Good catch! I'll take care of it right after scroll-into-view/compute-scroll-into-view#17 😄 |
I made a repro here: codepen.io/stipsan/pen/gjwWXV It is showing a behavior similar to what you mentioned above 🤔 |
I discovered an apparent bug, where I have something like this:
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 chainscrollIntoView
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.
The text was updated successfully, but these errors were encountered: