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 <noreply@anthropic.com>
This commit is contained in:
jamey 2026-03-27 10:36:02 +00:00
parent f47a4b90c7
commit 4ee097596b

View File

@ -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