MediaWiki:Common.js: Difference between revisions

mNo edit summary
mNo edit summary
Line 117: Line 117:


   const hash = window.location.hash;
   const hash = window.location.hash;
   if (!hash) return;                 // do nothing if no anchor
   if (!hash) return;


   const id = hash.replace('#','');
   const id = hash.replace('#','');
Line 125: Line 125:
     const item  = document.querySelector('.ooo-browser__item[data-target="'+id+'"]');
     const item  = document.querySelector('.ooo-browser__item[data-target="'+id+'"]');
     const panel = document.getElementById(id);
     const panel = document.getElementById(id);
     if (!item || !panel) return;
     if (!item || !panel) return;


Line 141: Line 140:


     panel.scrollIntoView({block:'start'});
     panel.scrollIntoView({block:'start'});
    /* IMPORTANT: remove hash so script does not re-trigger */
    history.replaceState(null, null, window.location.pathname);


   },200);
   },200);


});
});