From 8f6f6666a16211687ec83975fc3801b309cf197b Mon Sep 17 00:00:00 2001 From: Jamil Date: Thu, 13 Nov 2025 06:16:24 -1000 Subject: [PATCH] fix(portal): `phx-ignore` checkbox changes (#10879) On Resources and Policies forms, we were triggering the form's validation helpers when checking and unchecking a checkbox. Unfortunately this causes the checkbox to be reset since it was not saved across the to_form(changeset) rebuilding. To prevent this, we simply ignore checkbox changes from triggering form validations. We can also remove the `field=` property on these because we are setting the `checked` property ourselves. This will be refactored to be made simpler with the new modals approach, so a minimal fix is implemented for now. Related: https://firezonehq.slack.com/archives/C098RV5BL1K/p1763024374383399 Fixes: #9143 --- elixir/apps/web/lib/web/live/policies/components.ex | 3 +-- elixir/apps/web/lib/web/live/resources/components.ex | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/elixir/apps/web/lib/web/live/policies/components.ex b/elixir/apps/web/lib/web/live/policies/components.ex index e9046583d..49582db3c 100644 --- a/elixir/apps/web/lib/web/live/policies/components.ex +++ b/elixir/apps/web/lib/web/live/policies/components.ex @@ -650,11 +650,10 @@ defmodule Web.Policies.Components do

Allow access when the Client is manually verified by the administrator.

-
+
<.input type="checkbox" label="Require client verification" - field={condition_form[:values]} name="policy[conditions][client_verified][values][]" id="policy_conditions_client_verified_value" disabled={@disabled} diff --git a/elixir/apps/web/lib/web/live/resources/components.ex b/elixir/apps/web/lib/web/live/resources/components.ex index 851face7c..bdfbef6cb 100644 --- a/elixir/apps/web/lib/web/live/resources/components.ex +++ b/elixir/apps/web/lib/web/live/resources/components.ex @@ -138,11 +138,10 @@ defmodule Web.Resources.Components do ]}>
<.input type="hidden" name={"#{@form.name}[tcp][protocol]"} value="tcp" /> -
+
<.input title="Restrict traffic to TCP traffic" type="checkbox" - field={@forms_by_protocol[:tcp]} name={"#{@form.name}[tcp][enabled]"} checked={Map.has_key?(@forms_by_protocol, :tcp)} value="true" @@ -171,10 +170,9 @@ defmodule Web.Resources.Components do
<.input type="hidden" name={"#{@form.name}[udp][protocol]"} value="udp" /> -
+
<.input type="checkbox" - field={@forms_by_protocol[:udp]} name={"#{@form.name}[udp][enabled]"} checked={Map.has_key?(@forms_by_protocol, :udp)} value="true" @@ -204,11 +202,10 @@ defmodule Web.Resources.Components do
<.input type="hidden" name={"#{@form.name}[icmp][protocol]"} value="icmp" /> -
+
<.input title="Allow ICMP echo requests/replies" type="checkbox" - field={@forms_by_protocol[:icmp]} name={"#{@form.name}[icmp][enabled]"} checked={Map.has_key?(@forms_by_protocol, :icmp)} value="true"