I have a react component that needs to scroll to bottom given specific triggers. Following the answers in this SO question seemed like a nice and simple solution along these lines (full examples can be found in the question linked):
const scrollToBottom = () => {
if (messagesEndRef.current) {
messagesEndRef.current.scrollIntoView({ behavior: "smooth" });
}
};
However, after embedding the App in an iFrame it turns out that this will also trigger the parent page to scroll, which is bad. I tried different variations of the solution linked in the answer to this question, but without success.
Edit: some examples of those failed attempts:
// document.documentElement.scrollTop = messagesEndRef.current.offsetTop;
// messagesEndRef.current.parentNode.scrollTop = messagesEndRef.current.offsetTop;
Any pointer to how to achieve the same scrolling behavior but without affecting the iFrame parent page would be much appreciated.