Fix navigation menu buttons changing tab

Better fix

Affects:
- Note #1617
This commit is contained in:
Rsl1122 2020-10-20 16:43:26 +03:00
parent f46418d1f9
commit 19c904d047

View File

@ -52,8 +52,8 @@ for (let tab of tabs) {
window.addEventListener('hashchange', openPage); window.addEventListener('hashchange', openPage);
//Sidebar navigation tabs //Sidebar navigation tabs
$('#accordionSidebar .nav-button, #accordionSidebar .nav-button a').click(event => { $('#accordionSidebar .nav-item a').click(event => {
if (history.replaceState) { if (history.replaceState && event.currentTarget.href.split('#')[1].length > 0) {
event.preventDefault(); event.preventDefault();
history.replaceState(undefined, undefined, '#' + event.currentTarget.href.split('#')[1]); history.replaceState(undefined, undefined, '#' + event.currentTarget.href.split('#')[1]);
openPage(); openPage();
@ -66,7 +66,7 @@ $('.nav-tabs a.nav-link').click(event => {
if (!uriHash) return; if (!uriHash) return;
const currentTab = uriHash[0]; const currentTab = uriHash[0];
const originalTargetId = event.currentTarget.href.split('#')[1]; const originalTargetId = event.currentTarget.href.split('#')[1];
if(history.replaceState) { if (history.replaceState) {
event.preventDefault(); event.preventDefault();
history.replaceState(undefined, undefined, currentTab + '&' + originalTargetId); history.replaceState(undefined, undefined, currentTab + '&' + originalTargetId);
openPage(); openPage();