From ee64904caf41403204398f2f0d7705e9e7615343 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Fri, 2 Jan 2026 18:46:31 +0100 Subject: [PATCH] fix: update recipe translation store reactively during navigation Changed from onMount to $effect to ensure the recipeTranslationStore updates when navigating between recipes via client-side links. This fixes the language switcher incorrectly returning to the original recipe instead of switching the current recipe's language. --- src/routes/[recipeLang=recipeLang]/[name]/+page.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/[recipeLang=recipeLang]/[name]/+page.svelte b/src/routes/[recipeLang=recipeLang]/[name]/+page.svelte index 92333725..e02a9206 100644 --- a/src/routes/[recipeLang=recipeLang]/[name]/+page.svelte +++ b/src/routes/[recipeLang=recipeLang]/[name]/+page.svelte @@ -13,14 +13,14 @@ import RecipeNote from '$lib/components/RecipeNote.svelte'; import {stripHtmlTags} from '$lib/js/stripHtmlTags'; import FavoriteButton from '$lib/components/FavoriteButton.svelte'; - import RecipeLanguageSwitcher from '$lib/components/RecipeLanguageSwitcher.svelte'; - import { onMount, onDestroy } from 'svelte'; + import { onDestroy } from 'svelte'; import { recipeTranslationStore } from '$lib/stores/recipeTranslation'; let { data }: { data: PageData } = $props(); // Set store for recipe translation data so UserHeader can access it - onMount(() => { + // Use $effect instead of onMount to react to data changes during client-side navigation + $effect(() => { recipeTranslationStore.set({ germanShortName: data.germanShortName || data.short_name, englishShortName: data.englishShortName,