fix: load correct tab when we load up
This commit is contained in:
parent
1790977744
commit
7e3a73c9f8
1 changed files with 9 additions and 3 deletions
|
@ -1,19 +1,23 @@
|
|||
<script>
|
||||
window.addEventListener("locationchange", () => {
|
||||
function on_location_change() {
|
||||
const hash = window.location.hash?.slice(1);
|
||||
console.dir({ hash });
|
||||
if (hash) {
|
||||
const target_tab_url = hash.slice(0, hash.slice(1).indexOf("/") + 1);
|
||||
const target_tab = document.querySelector(`[data-hash="${target_tab_url}"]`);
|
||||
|
||||
console.dir({
|
||||
hash,
|
||||
target_tab_url,
|
||||
target_tab,
|
||||
});
|
||||
|
||||
if (target_tab) {
|
||||
target_tab.click();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener("locationchange", on_location_change);
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const tab_switchers = document.querySelectorAll(".tab-switch");
|
||||
|
@ -26,6 +30,8 @@
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
on_location_change();
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue