fix: load correct tab when we load up

This commit is contained in:
Andy Burke 2025-07-25 14:36:53 -07:00
parent 1790977744
commit 7e3a73c9f8

View file

@ -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>