Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile Menu issue when using anchor links in Nav #165

Closed
danp-dev opened this issue May 8, 2023 · 1 comment
Closed

Mobile Menu issue when using anchor links in Nav #165

danp-dev opened this issue May 8, 2023 · 1 comment

Comments

@danp-dev
Copy link

danp-dev commented May 8, 2023

I build out some sections on the homepage of the template, I added anchor links to the navbar so a site user can jump between sections of the page.

When using the site on mobile, I noticed that the links work (they take you to the correct section of the page as I can see the url change) But the mobile menu does not disappear.

The BasicScripts.Astro file has an attach event and an onpageshow event that look to be handling the display property for the mobile menu.

attachEvent('[data-aw-toggle-menu]', 'click', function (_, elem) {
elem.classList.toggle('expanded');
document.body.classList.toggle('overflow-hidden');
document.getElementById('header')?.classList.toggle('h-screen');
document.querySelector('#header nav')?.classList.toggle('hidden');
});

window.onpageshow = function () {
document.documentElement.classList.add('motion-safe:scroll-smooth');
const elem = document.querySelector('[data-aw-toggle-menu]');
if (elem) {
  elem.classList.remove('expanded');
}
document.body.classList.remove('overflow-hidden');
document.getElementById('header')?.classList.remove('h-screen');
document.querySelector('#header nav')?.classList.add('hidden');

};

prototypa added a commit that referenced this issue Jun 18, 2023
@prototypa
Copy link
Contributor

Hi @danp-dev

For now we add a small fix in BasicScripts.astro to solve this problem. Please check that everything is as you expect and let us know. Thank you.

Commit: 8ff3675

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants