Search code examples
reactjsmaterial-uiref

UI moves when I put a ref in a Box/div


I have the following code:

enter image description here

and it looks like this:

enter image description here

I need to add a div with a reference inside it:

enter image description here

And if I do so, all the UI moves up. See this picture:

enter image description here

I realized this happens only when I add the ref attribute to the div. Can anyone help me understand why this is happening?


Solution

  • you can do that easily by using scrollTop property, find scrollable element and set scrollTop to 0, document.getElementById('#eampleScrollableDiv').scrollTop = 0