From 30c639c5de59100b3318b55378c4453b7dfa5378 Mon Sep 17 00:00:00 2001 From: SrGesus <108523575+SrGesus@users.noreply.github.com> Date: Sun, 26 Jan 2025 01:12:47 +0000 Subject: [PATCH 1/2] fix: Reset cached recipe when edit is closed --- frontend/components/Domain/Recipe/RecipePage/RecipePage.vue | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/components/Domain/Recipe/RecipePage/RecipePage.vue b/frontend/components/Domain/Recipe/RecipePage/RecipePage.vue index 781ffda7b..b6b7d420d 100644 --- a/frontend/components/Domain/Recipe/RecipePage/RecipePage.vue +++ b/frontend/components/Domain/Recipe/RecipePage/RecipePage.vue @@ -234,7 +234,7 @@ export default defineComponent({ onUnmounted(async () => { const isSame = JSON.stringify(props.recipe) === JSON.stringify(originalRecipe.value); - if (isEditMode.value && !isSame && props.recipe?.slug !== undefined) { + if (!isSame && props.recipe?.slug !== undefined) { const save = window.confirm( i18n.tc("general.unsaved-changes"), ); @@ -274,7 +274,8 @@ export default defineComponent({ const { data } = await api.recipes.updateOne(props.recipe.slug, props.recipe); setMode(PageMode.VIEW); if (data?.slug) { - router.push(`/g/${groupSlug.value}/r/` + data.slug); + Object.assign(originalRecipe.value, props.recipe); + router.push(`/g/${groupSlug.value}/r/${data.slug}`); } } From 269706fb0920b9beaf47e4471b2806e24962a1a3 Mon Sep 17 00:00:00 2001 From: SrGesus <108523575+SrGesus@users.noreply.github.com> Date: Mon, 27 Jan 2025 18:08:20 +0000 Subject: [PATCH 2/2] fix: Add snackbar to indicate unsaved changes --- .../Domain/Recipe/RecipePage/RecipePage.vue | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/frontend/components/Domain/Recipe/RecipePage/RecipePage.vue b/frontend/components/Domain/Recipe/RecipePage/RecipePage.vue index b6b7d420d..ebf61baf8 100644 --- a/frontend/components/Domain/Recipe/RecipePage/RecipePage.vue +++ b/frontend/components/Domain/Recipe/RecipePage/RecipePage.vue @@ -1,5 +1,20 @@