From 2dbfc7f72b0c4f47e2cca6a7637ec03b01976278 Mon Sep 17 00:00:00 2001 From: Zdenek Stursa <90236729+zdenek-stursa@users.noreply.github.com> Date: Mon, 11 May 2026 17:13:16 +0200 Subject: [PATCH] fix: redirect to new slug URL after recipe rename (#7522) Co-authored-by: Claude Sonnet 4.6 --- .../Domain/Recipe/RecipePage/RecipePage.vue | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/app/components/Domain/Recipe/RecipePage/RecipePage.vue b/frontend/app/components/Domain/Recipe/RecipePage/RecipePage.vue index e7fd9f95d..d63ac50c4 100644 --- a/frontend/app/components/Domain/Recipe/RecipePage/RecipePage.vue +++ b/frontend/app/components/Domain/Recipe/RecipePage/RecipePage.vue @@ -336,8 +336,16 @@ onMounted(() => { } }); +// When set, the isEditMode watcher skips its URL cleanup because saveRecipe +// is navigating to a new slug that naturally omits ?edit=true. +const isNavigatingAfterRename = ref(false); + watch(isEditMode, (newVal) => { if (!newVal) { + if (isNavigatingAfterRename.value) { + isNavigatingAfterRename.value = false; + return; + } paramsEdit.value = undefined; } }); @@ -355,13 +363,17 @@ watch(isParsing, () => { async function saveRecipe() { const { data, error } = await api.recipes.updateOne(recipe.value.slug, recipe.value); if (!error) { + if (data?.slug && data.slug !== route.params.slug) { + isNavigatingAfterRename.value = true; + } setMode(PageMode.VIEW); } if (data?.slug) { - router.push(`/g/${groupSlug.value}/r/` + data.slug); recipe.value = data as NoUndefinedField; - // Update the snapshot after successful save originalRecipe.value = deepCopy(recipe.value); + if (data.slug !== route.params.slug) { + router.replace(`/g/${groupSlug.value}/r/` + data.slug); + } } }