menuspy icon indicating copy to clipboard operation
menuspy copied to clipboard

Side Menu : Bug section title problem after page refresh

Open lenamtl opened this issue 8 years ago • 1 comments

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

lenamtl avatar Oct 25 '17 17:10 lenamtl

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');
    },
  });

ygd avatar Mar 27 '20 20:03 ygd