Hello everyone,
I’m using ~p
in one of my liveviews to push_patch
based on an event and the resulting path from the snippet below appears to be messed up where the /
s are replaced with %2F
s regardless of whether I include query params or not. I’m not sure where I’m going wrong here, any help please?
def handle_info({:update, opts}, socket) do
params = PaginationForm.merge_and_sanitize_params(socket, opts)
current_path = socket.assigns.current_path
|> String.trim_leading("/")
path = ~p"/#{current_path}"
{:noreply, push_patch(socket, to: path, replace: true)}
end
affixing the query params with path = ~p"/#{current_path}?#{params}"
has no effect. The resulting path/error is like so:
** (ArgumentError) cannot push_patch/2 to %URI{scheme: "http",
userinfo: nil,
host: "localhost",
port: 4000,
path: "/en%2Fitems%2F1%2Fstatement",
query: query: "page=1&page_size=10",
fragment: nil}
because the given path does not point to the current root view
...
The relevant router path is defined in a locale scope:
scope "/:locale", MyAppWeb do
pipe_through [:browser, :localization, :require_authenticated_user]
live "/items/:id/statement", ItemLive.Show, :statement
The app uses Phoenix 1.7.11 (recent upgrade)
Thanks in advance!