From 46f65d9adb9dd220f6043e6589fc48865a905710 Mon Sep 17 00:00:00 2001 From: Adam Rutkowski Date: Tue, 9 Jan 2024 12:11:03 +0100 Subject: [PATCH] Make sure `:selection_made` is handled in `GoalSettings.Form` That was a bit unepexcted.. normally `handle_info` is injected by the LiveView use macro and it discards any message gracefully. After switching to `use PlausibleWeb, :live_view` we're also using `PlausibleWeb.Live.Flash` that happens to inject its own receive clause for closing the flash. Which then renders the original, overridable, `handle_info` catch-all obsolete. --- lib/plausible_web/live/goal_settings/form.ex | 4 ++++ test/plausible_web/live/goal_settings/form_test.exs | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/lib/plausible_web/live/goal_settings/form.ex b/lib/plausible_web/live/goal_settings/form.ex index c01613150..0f53babbd 100644 --- a/lib/plausible_web/live/goal_settings/form.ex +++ b/lib/plausible_web/live/goal_settings/form.ex @@ -268,6 +268,10 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do """ end + def handle_info({:selection_made, %{submit_value: _prop}}, socket) do + {:noreply, socket} + end + def handle_event("switch-tab", _params, socket) do {:noreply, assign(socket, diff --git a/test/plausible_web/live/goal_settings/form_test.exs b/test/plausible_web/live/goal_settings/form_test.exs index defbacb07..287df7387 100644 --- a/test/plausible_web/live/goal_settings/form_test.exs +++ b/test/plausible_web/live/goal_settings/form_test.exs @@ -129,6 +129,13 @@ defmodule PlausibleWeb.Live.GoalSettings.FormTest do refute element_exists?(html, ~s/a[phx-value-display-value="PLN - Polish Zloty"]/) assert element_exists?(html, ~s/a[phx-value-display-value="EUR - Euro"]/) + + lv + |> element("#dropdown-currency_input-option-1 a") + |> render_click() + + # make sure combo's {:selection_made, ...} message is received + render(lv) end test "pageview combo works", %{conn: conn, site: site} do