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

Fix Responsive Global Nav #764

Merged
merged 1 commit into from
Nov 22, 2024
Merged

Conversation

glenn-sorrentino
Copy link
Member

The global navigation menu was not functioning on responsive (mobile) sizes. Clicking the “Menu” button had no effect due to missing JavaScript handling for toggling the mobile navigation menu.

Solution

  • Added setupMobileNav() function:
  • Selects the mobile navigation button (.mobileNav) and the navigation menu list (header nav ul).
  • Adds a click event listener to the mobile navigation button.
  • Toggles the show class on the navigation <ul> to control menu visibility, matching the existing CSS.
  • Adjusted navController() function:
  • Called the new setupMobileNav() function to initialize mobile navigation handling.

Outcome

  • The mobile navigation menu now works correctly on responsive sizes.
  • Clicking the “Menu” button toggles the visibility of the navigation menu as expected.
  • The navigation menu functions correctly on both mobile and desktop views.
function navController() {
  // Existing dropdown setup
  setupDropdown();

  // New mobile navigation setup
  setupMobileNav();
}

function setupMobileNav() {
  const mobileNavToggle = document.querySelector(".mobileNav");
  const navList = document.querySelector("header nav ul");

  if (mobileNavToggle && navList) {
    mobileNavToggle.addEventListener("click", function (event) {
      event.preventDefault();
      navList.classList.toggle("show");
      const expanded = this.getAttribute("aria-expanded") === "true" || false;
      this.setAttribute("aria-expanded", !expanded);
    });
  }
}

@brassy-endomorph brassy-endomorph merged commit fcb738c into refactor-settings-pages Nov 22, 2024
2 of 3 checks passed
@brassy-endomorph brassy-endomorph deleted the nav-fix branch November 22, 2024 09:13
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

Successfully merging this pull request may close these issues.

2 participants