From b837abdba00eb88554cd59cffaa430fdb7fc5499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gremaud?= Date: Thu, 15 Oct 2026 23:36:06 +0200 Subject: [PATCH] fix(submissions): having one scope only make the back return not work --- polylan_submitter/src/Submissions.vue | 5 +++++ polylan_submitter/src/layout/AppHeader.vue | 4 ++-- polylan_submitter/src/stores/pageHeader.ts | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/polylan_submitter/src/Submissions.vue b/polylan_submitter/src/Submissions.vue index a3a38b2..8cd7a10 100644 --- a/polylan_submitter/src/Submissions.vue +++ b/polylan_submitter/src/Submissions.vue @@ -528,6 +528,11 @@ onMounted(async () => { return; } scopeName.value = scope.name; + // The picker auto-redirects back here when there's only one scope, so + // going "back" to it would loop - head to the event home instead. + if (scopesResponse.data?.length === 1) { + pageHeaderStore.setBackRoute({ name: "home", params: { eventPath: props.eventPath } }); + } pageHeaderStore.setTitle(t("submissions.pageTitle", { game: gameName.value, scope: scopeName.value })); // Add paste listener (only processes if hovering upload area) diff --git a/polylan_submitter/src/layout/AppHeader.vue b/polylan_submitter/src/layout/AppHeader.vue index ee69994..c6b35e1 100644 --- a/polylan_submitter/src/layout/AppHeader.vue +++ b/polylan_submitter/src/layout/AppHeader.vue @@ -12,7 +12,7 @@ const { t } = useI18n(); const userStore = useUserStore(); const { userInfo } = storeToRefs(userStore); const pageHeaderStore = usePageHeaderStore(); -const { title: dynamicTitle } = storeToRefs(pageHeaderStore); +const { title: dynamicTitle, backRoute: dynamicBackRoute } = storeToRefs(pageHeaderStore); const title = computed(() => { if (dynamicTitle.value) return dynamicTitle.value; @@ -21,7 +21,7 @@ const title = computed(() => { }); const goBack = () => { - const backRoute = route.meta.getBackRoute?.(route); + const backRoute = dynamicBackRoute.value ?? route.meta.getBackRoute?.(route); if (backRoute) { router.push(backRoute); } diff --git a/polylan_submitter/src/stores/pageHeader.ts b/polylan_submitter/src/stores/pageHeader.ts index d9af51a..deb9839 100644 --- a/polylan_submitter/src/stores/pageHeader.ts +++ b/polylan_submitter/src/stores/pageHeader.ts @@ -1,5 +1,6 @@ import { defineStore } from "pinia"; import { ref } from "vue"; +import type { RouteLocationRaw } from "vue-router"; // Lets a routed page hand AppHeader a title built from data only that page // has fetched (e.g. "Noita Submissions — Semifinal", assembled from an API @@ -7,14 +8,22 @@ import { ref } from "vue"; // stale title never lingers while the next page is still loading. export const usePageHeaderStore = defineStore("pageHeader", () => { const title = ref(""); + // Overrides route.meta.getBackRoute when the right target depends on + // fetched data (e.g. skip the scope picker when it would auto-redirect). + const backRoute = ref(null); const setTitle = (value: string) => { title.value = value; }; - const clear = () => { - title.value = ""; + const setBackRoute = (value: RouteLocationRaw) => { + backRoute.value = value; }; - return { title, setTitle, clear }; + const clear = () => { + title.value = ""; + backRoute.value = null; + }; + + return { title, backRoute, setTitle, setBackRoute, clear }; });