feat: use router.replace for project filters to prevent history pollution (#5378)
* fix(navigation): use replaceState for project filters to prevent history pollution * fix: add replace prop to NavTabs and enable it on project and discover pages * style: run pnpm run fix on affected files * enable NavTabs replace prop on collection, user, and org pages --------- Co-authored-by: Calum H. (IMB11) <contact@cal.engineer>
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
v-show="link.shown ?? true"
|
v-show="link.shown ?? true"
|
||||||
:key="link.href"
|
:key="link.href"
|
||||||
ref="tabLinkElements"
|
ref="tabLinkElements"
|
||||||
|
:replace="replace"
|
||||||
:to="query ? (link.href ? `?${query}=${link.href}` : '?') : link.href"
|
:to="query ? (link.href ? `?${query}=${link.href}` : '?') : link.href"
|
||||||
class="button-animation z-[1] flex flex-row items-center gap-2 px-4 py-2 focus:rounded-full"
|
class="button-animation z-[1] flex flex-row items-center gap-2 px-4 py-2 focus:rounded-full"
|
||||||
:class="getSSRFallbackClasses(index)"
|
:class="getSSRFallbackClasses(index)"
|
||||||
@@ -71,6 +72,7 @@ interface Tab {
|
|||||||
|
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
|
replace?: boolean
|
||||||
links: Tab[]
|
links: Tab[]
|
||||||
query?: string
|
query?: string
|
||||||
mode?: 'navigation' | 'local'
|
mode?: 'navigation' | 'local'
|
||||||
|
|||||||
@@ -100,12 +100,12 @@
|
|||||||
() => {
|
() => {
|
||||||
debug('on-show fired')
|
debug('on-show fired')
|
||||||
loadVersions()
|
loadVersions()
|
||||||
navigateTo({ query: route.query, hash: '#download' })
|
navigateTo({ query: route.query, hash: '#download' }, { replace: true })
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
:on-hide="
|
:on-hide="
|
||||||
() => {
|
() => {
|
||||||
navigateTo({ query: route.query, hash: '' })
|
navigateTo({ query: route.query, hash: '' }, { replace: true })
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
@@ -243,18 +243,21 @@
|
|||||||
platformAccordion.open()
|
platformAccordion.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateTo({
|
navigateTo(
|
||||||
query: {
|
{
|
||||||
...route.query,
|
query: {
|
||||||
...(userSelectedGameVersion && {
|
...route.query,
|
||||||
version: userSelectedGameVersion,
|
...(userSelectedGameVersion && {
|
||||||
}),
|
version: userSelectedGameVersion,
|
||||||
...(userSelectedPlatform && {
|
}),
|
||||||
loader: userSelectedPlatform,
|
...(userSelectedPlatform && {
|
||||||
}),
|
loader: userSelectedPlatform,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
hash: route.hash,
|
||||||
},
|
},
|
||||||
hash: route.hash,
|
{ replace: true },
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
@@ -344,18 +347,21 @@
|
|||||||
gameVersionAccordion.open()
|
gameVersionAccordion.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateTo({
|
navigateTo(
|
||||||
query: {
|
{
|
||||||
...route.query,
|
query: {
|
||||||
...(userSelectedGameVersion && {
|
...route.query,
|
||||||
version: userSelectedGameVersion,
|
...(userSelectedGameVersion && {
|
||||||
}),
|
version: userSelectedGameVersion,
|
||||||
...(userSelectedPlatform && {
|
}),
|
||||||
loader: userSelectedPlatform,
|
...(userSelectedPlatform && {
|
||||||
}),
|
loader: userSelectedPlatform,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
hash: route.hash,
|
||||||
},
|
},
|
||||||
hash: route.hash,
|
{ replace: true },
|
||||||
})
|
)
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
@@ -1009,7 +1015,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="normal-page__content">
|
<div class="normal-page__content">
|
||||||
<div class="overflow-x-auto"><NavTabs :links="navLinks" class="mb-4" /></div>
|
<div class="overflow-x-auto"><NavTabs :links="navLinks" replace class="mb-4" /></div>
|
||||||
<NuxtPage @on-download="triggerDownloadAnimation" @delete-version="deleteVersion" />
|
<NuxtPage @on-download="triggerDownloadAnimation" @delete-version="deleteVersion" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -286,6 +286,7 @@
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
]"
|
]"
|
||||||
|
replace
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ProjectCardList
|
<ProjectCardList
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ const selectableProjectTypes = [
|
|||||||
<NavTabs
|
<NavTabs
|
||||||
v-if="!flags.projectTypesPrimaryNav && allowTabChanging"
|
v-if="!flags.projectTypesPrimaryNav && allowTabChanging"
|
||||||
:links="selectableProjectTypes"
|
:links="selectableProjectTypes"
|
||||||
|
replace
|
||||||
class="hidden md:flex"
|
class="hidden md:flex"
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -184,7 +184,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="navLinks.length > 2" class="mb-4 max-w-full overflow-x-auto">
|
<div v-if="navLinks.length > 2" class="mb-4 max-w-full overflow-x-auto">
|
||||||
<NavTabs :links="navLinks" />
|
<NavTabs :links="navLinks" replace />
|
||||||
</div>
|
</div>
|
||||||
<ProjectCardList v-if="projects && projects.length > 0">
|
<ProjectCardList v-if="projects && projects.length > 0">
|
||||||
<template
|
<template
|
||||||
|
|||||||
@@ -283,7 +283,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="normal-page__content">
|
<div class="normal-page__content">
|
||||||
<div v-if="navLinks.length > 2" class="mb-4 max-w-full overflow-x-auto">
|
<div v-if="navLinks.length > 2" class="mb-4 max-w-full overflow-x-auto">
|
||||||
<NavTabs :links="navLinks" />
|
<NavTabs :links="navLinks" replace />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="projects.length > 0">
|
<div v-if="projects.length > 0">
|
||||||
<ProjectCardList
|
<ProjectCardList
|
||||||
|
|||||||
Reference in New Issue
Block a user