Disable scrolling to the gallery on variant change in Shopify Dawn theme

Dawn theme in Shopify by default changes the order of images depending on the variant selection and automatically scrolls to the gallery container.

This all works great but on mobile it scrolls the user to the top and the user has to scroll back down if he wants to select another variant or add to cart.

For the Dawn theme this code is present in the /assets/media-gallery.js file. We want to keep the image order swap when switching variants but disable the scrolling to the gallery. The following code does that.

// In the setActiveMedia method on line 31 find the window.setTimeout function and chage it to the following.
window.setTimeout(() => {
  if (this.elements.thumbnails) {
    activeMedia.parentElement.scrollTo({ left: activeMedia.offsetLeft });
  if (!this.elements.thumbnails || this.dataset.desktopLayout === 'stacked') {
    // Disable scrolling to gallery on variant change
    // activeMedia.scrollIntoView({ behavior: 'smooth' });
    // Still change the slide to the selected variant
    activeMedia.parentElement.scrollTo({ left: activeMedia.offsetLeft });