From 4ee097596b6be5179d9d533a0efbab684ca9e50d Mon Sep 17 00:00:00 2001 From: jamey Date: Fri, 27 Mar 2026 10:36:02 +0000 Subject: [PATCH] fix editor blocks not syncing on content page navigation Move maybe_sync_editing_blocks to run after module.handle_params since Content pages (about, delivery, privacy, terms) set @page in handle_params rather than init. Previously editing_blocks would show stale content from the previous page. Co-Authored-By: Claude Opus 4.5 --- lib/berrypod_web/live/shop/page.ex | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/berrypod_web/live/shop/page.ex b/lib/berrypod_web/live/shop/page.ex index 05e719f..a6397af 100644 --- a/lib/berrypod_web/live/shop/page.ex +++ b/lib/berrypod_web/live/shop/page.ex @@ -217,9 +217,6 @@ defmodule BerrypodWeb.Shop.Page do socket end - # After page init, sync editor state if editing and page changed - socket = maybe_sync_editing_blocks(socket) - # Scroll to top on navigation (different path, not just query param changes) socket = if prev_path && prev_path != current_path do @@ -230,10 +227,17 @@ defmodule BerrypodWeb.Shop.Page do socket = assign(socket, :_current_path, current_path) - # Always call handle_params for URL changes - case module.handle_params(params, uri, socket) do - {:noreply, socket} -> {:noreply, socket} - end + # Always call handle_params for URL changes - some pages (Content) set @page here + socket = + case module.handle_params(params, uri, socket) do + {:noreply, socket} -> socket + end + + # After module.handle_params, sync editor state if editing and page changed. + # Must run after handle_params since Content pages set @page there. + socket = maybe_sync_editing_blocks(socket) + + {:noreply, socket} end # If editing and we navigated to a different page, reload editing_blocks