0

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.

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

1 Answer 1

0

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

https://stackoverflow.com/questions/16910362/how-to-scroll-to-the-top-of-a-modal-window-in-javascript

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

1
  • Hello, any idea how to achieve similar behaviour in salesforce mobile app?
    – jm.
    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 .