Dawn theme header is not being sticky

Topic summary

A user is experiencing an issue with the Dawn theme where opening the mobile hamburger menu causes the page to scroll to the bottom, despite wanting a sticky header.

Proposed Solution:
A community member suggested overriding the menu drawer’s CSS and JavaScript behavior by:

  • Adding CSS to theme.css or base.css to fix the menu drawer position and prevent scroll jumps
  • Implementing JavaScript code (either in theme.liquid before the closing </body> tag or in assets/header-drawer.js) to lock scroll behavior

Implementation Details:
The helper provided two placement options for the JavaScript snippet with step-by-step instructions for accessing the theme code editor.

Current Status:
The issue remains unresolved — the original poster reported that the suggested fix did not work and has requested additional help. No further solutions have been provided yet.

Summarized with AI on October 25. AI used: claude-sonnet-4-5-20250929.

I’m using the Dawn theme because I want the mobile header to be sticky. When I open the mobile hamburger menu, the page scrolls to the bottom. Can someone help me fix this?

Website: https://ambersilverz.myshopify.com/
Password: amber

You can fix this by overriding the menu drawer CSS and JS behavior. Try adding this snippet in your theme.css (or base.css):

/* Prevent page scroll jump when opening mobile menu */
.menu-drawer {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

And in theme.liquid or header-drawer.js, ensure scroll locking doesn’t force a jump. Add:

document.addEventListener('DOMContentLoaded', function() {
  const menuDrawer = document.querySelector('.menu-drawer')
  if (menuDrawer) {
    menuDrawer.addEventListener('transitionend', () => {
      window.scrollTo(0,0)
    })
  }
})

  1. The header stays sticky.
  2. When you open the hamburger menu, it slides out smoothly without pushing the page down.
  3. User experience feels seamless.

@Fayyaz_Ahmed where to place the below js code, under which tag

Hi Sivadarshan,

Good question. You can add that JS snippet in one of two safe places:

Option 1 – Directly in theme.liquid

  1. Go to Online Store > Themes > Edit code

  2. Open layout/theme.liquid

  3. Scroll to the bottom, just before the closing </body> tag

  4. Paste the script:

<script>
  document.addEventListener('DOMContentLoaded', function() {
    const menuDrawer = document.querySelector('.menu-drawer')
    if (menuDrawer) {
      menuDrawer.addEventListener('transitionend', () => {
        window.scrollTo(0,0)
      })
    }
  })
</script>

Option 2 – Inside header-drawer.js

  • If you prefer to keep everything in JS files, open assets/header-drawer.js

  • Paste the code at the bottom of that file.

  • Save and publish.


Sorry it’s not working, can you please help with me