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

Side Menu : Bug section title problem after page refresh #9

Open
lenamtl opened this issue Oct 25, 2017 · 1 comment
Open

Side Menu : Bug section title problem after page refresh #9

lenamtl opened this issue Oct 25, 2017 · 1 comment

Comments

@lenamtl
Copy link

lenamtl commented Oct 25, 2017

Hi,

There is a problem after page refresh

How to reproduce :
https://leocs.me/menuspy/examples/sidemenu.html
click on the latest bullet (section-3)
refresh the page
click on any other bullet let say section-2
the section title 3 stay active while section are changing

@ygd
Copy link

ygd commented Mar 27, 2020

Setting the active class name in the callback seems to fix this:

  var sideNav = document.querySelector('#sideNav');
  var ms = new MenuSpy(sideNav, {
    callback: function(currentItem) {
      var isCurrentItemActive = currentItem.elm.parentNode.classList.contains('active');
      if (isCurrentItemActive) return;
      sideNav
        .querySelector('.active')
        .classList.remove('active');
      currentItem.elm.parentNode.classList.add('active');
    },
  });

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