Kirby panel breaking `window.scrollTo`. Why? How to fix?

Reproduction steps:

  • Go to Kirby panel
  • Open developer console
  • Try to scroll the page programmatically using window.scrollTo, e.g. window.scrollTo(0, 1000)
  • Expect to see the page scroll (this works on every website I’ve tried, expect in the Kirby panel)
  • Observe instead that nothing happens (and no errors either)

I don’t understand why this doesn’t work here.

I found this while troubleshooting why my scroll listeners are working on the front end but not in the panel. Is the panel intercepting scroll events or something?

I’ve discovered this is because it is the <main> that is scrolling and not the body. So the solution is window.document.querySelector('main').scrollTo(0, 1000).
As for scroll listeners, using capture: true on a listener on the window will work no matter what is scrolling.