i have a modal popup with scrolling, i am trying to scroll the user to the top of the modal when the user clicks on a button. window.scrollTo(0,0) is scrolling the main window not the modal.

  • what do you think window.scrollTo(0,0) is acting upon?
    – Nick C
    Commented Jan 28, 2021 at 11:59
  • on the main window, means the behind one. Commented Jan 28, 2021 at 12:41

1 Answer 1


You should select your modal window specificly and use the scroll on it. Please see if this article would help it seems fairly straightforward:


Also keep in mind that in LWC you might be missing some JS libaries described in the help article.

Here is another one made specificly for LWC:

A button to scroll at the top of the page in LWC

  • Hello, any idea how to achieve similar behaviour in salesforce mobile app?
    – jm.
    Commented Jun 14, 2021 at 16:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .