fix: prefer fallback for back button most of the time

This commit is contained in:
Julien Calixte
2026-02-15 21:18:44 +01:00
parent 1c3120e4f7
commit 28a2bd8e31
2 changed files with 13 additions and 2 deletions

View File

@@ -1,10 +1,18 @@
<script setup lang="ts">
import { useRouter, type RouteLocationRaw } from "vue-router"
const props = defineProps<{ fallback?: RouteLocationRaw }>()
const props = withDefaults(
defineProps<{ fallback?: RouteLocationRaw; preferFallback?: boolean }>(),
{ preferFallback: true },
)
const router = useRouter()
const goBack = () => {
if (props.preferFallback && props.fallback) {
router.push(props.fallback)
return
}
if (window.history.state?.back) {
router.back()
} else if (props.fallback) {