Scrolling on element happens only the first time
saurishkar opened this issue · comments
I have a slider of elements and a large view below the slider that is mounted when an element is clicked.
I have used scrollIntoViewIfNeeded when the large view component gets mounted.
It scrolls nicely the first time, but when i close the view and then open it again. It does not scroll.
I am guessing here but when you close the view and open it again, does scrollIntoViewIfNeeded
get fired?
Everytime it is called it will measure the DOM node you're passing in, so wether you're calling it for the first time, or the 100th time shouldn't make a difference.
However the timing of when you call it does make a difference. There could be a race condition happening between the closing and opening of your view that is causing it to try and measure if your node is visible or not at the wrong time (before it is mounted again).
Can you share some code, or better yet use something like codesandbox to recreate the problem? If you do that I'll be able to give much better help 😄
This should no longer happen in v2