Skip to content

Commit

Permalink
clear selection when switching mode
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmarcon committed Dec 3, 2023
1 parent 8f6a346 commit 6bc7391
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/support/live_select_web/live/showcase_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ defmodule LiveSelectWeb.ShowcaseLive do
@impl true
def handle_event(
"update-settings",
%{"settings" => params},
%{"settings" => params, "_target" => target},
socket
) do
params =
Expand All @@ -295,6 +295,13 @@ defmodule LiveSelectWeb.ShowcaseLive do

socket =
socket
|> update(:live_select_form, fn form ->
if target == ["settings", "mode"] do
to_form(%{}, as: :my_form)
else
form
end
end)
|> push_patch(to: ~p(/?#{params}))

{:noreply, socket}
Expand Down

0 comments on commit 6bc7391

Please sign in to comment.