I'm attempting to prevent the page from scrolling whenever a button is pressed in a form with a required input. Here is an example of what I am referring to.
To see what I mean, scroll the viewer on the right all the way down and press the button, it should scroll the view all the way up to the required input field.
I need a way to prevent this, I've attempted adding listeners for event such as onScroll
or onClick
. The closest to a solution I have found is to add a listener on the document for the scroll
event and stop propagation of the event, however this prevents normal scrolling from the user as well.