Hi. I am new to react so this issue might be something obvious for others. I have done some research but could not find a solution on my own.
I have created a simple component showing a table as in Table.Example.js from the source. I have not added anything else and not passing any props to this specific component.
What happen is the following:
1) I scroll down the main page and also select (it's outlined) and scroll down the table, then if react triggers a render because of some changes in the props passed down by parents, the page scroll position is set to the top.
2) I scroll down the main page and scroll the table but do not leave it selected (it's not outlined), the above behaviours does not happen. The page is rendered again on props changes but the scroll position is not changed.
Any advice?
For the moment I've fixed it with something like this, but I am unsure whether is the correct solution.
scrollPosition = 0
componentWillReceiveProps () {
const element = ReactDOM.findDOMNode(this);
if (element != null) {
this.scrollPosition = window.scrollY
}
}
componentDidUpdate () {
const element = ReactDOM.findDOMNode(this);
if (element != null) {
window.scrollTo(0, this.scrollPosition)
}
}
There seems to be a bug in 9.12 with scrollPosition causing the scroll offset to get stuck. Probably a regression from a recent change to the way that property is handled.
Going to close this as a duplicate of #884. I'm pretty sure the underlying cause is the same, and the issue has a repro case attached.
Most helpful comment
For the moment I've fixed it with something like this, but I am unsure whether is the correct solution.