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> <script>
window.addEventListener("locationchange", () => { function on_location_change() {
const hash = window.location.hash?.slice(1); const hash = window.location.hash?.slice(1);
console.dir({ hash });
if (hash) { if (hash) {
const target_tab_url = hash.slice(0, hash.slice(1).indexOf("/") + 1); const target_tab_url = hash.slice(0, hash.slice(1).indexOf("/") + 1);
const target_tab = document.querySelector(`[data-hash="${target_tab_url}"]`); const target_tab = document.querySelector(`[data-hash="${target_tab_url}"]`);
console.dir({ console.dir({
hash,
target_tab_url, target_tab_url,
target_tab, target_tab,
}); });
if (target_tab) { if (target_tab) {
target_tab.click(); target_tab.click();
} }
} }
}); }
window.addEventListener("locationchange", on_location_change);
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
const tab_switchers = document.querySelectorAll(".tab-switch"); const tab_switchers = document.querySelectorAll(".tab-switch");
@ -26,6 +30,8 @@
} }
}); });
} }
on_location_change();
}); });
</script> </script>
<style> <style>