Skip to content

Commit

Permalink
fix: navigating tabs through back button works now!
Browse files Browse the repository at this point in the history
  • Loading branch information
Draconizations committed Oct 5, 2024
1 parent bebab27 commit 132c10f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/routes/dash/[sid]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<script lang="ts">
import { replaceState } from "$app/navigation"
import { goto, pushState } from "$app/navigation"
import { page } from "$app/stores"
import GroupHome from "$components/dash/groups/GroupHome.svelte"
import MemberHome from "$components/dash/members/MemberHome.svelte"
import Overview from "$components/dash/overview/Overview.svelte"
import SystemHome from "$components/dash/system/SystemHome.svelte"
let { data } = $props()
let tab = $state(data.tab || "overview")
$effect(() => {
tab = data.tab
})
let tab = $state($page.url.searchParams.get("tab") || data.tab || "overview")
function changeTab(newTab: string) {
let params = $page.url.searchParams.toString()
params = params.replace(/tab=.*(?:$|&)/g, "")
replaceState(`?tab=${newTab}${params ? "&" + params : ""}`, {})
let params = $page.url.searchParams
params.delete("tab")
params.append("tab", newTab)
goto(`?${params.toString()}`, {})
tab = newTab
}
</script>
Expand Down

0 comments on commit 132c10f

Please sign in to comment.